import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:tp5/widgets/nav_drawer.dart'; class BasicPage extends ConsumerStatefulWidget { final String? title; final Widget body; final AppBar? appBar; final Widget? drawer; final Widget? floatingActionButton; final Widget? bottomSheet; final List? persistentFooterButtons; final dynamic floatingActionButtonLocation; final Widget? bottomNavigationBar; final List? actions; const BasicPage({ this.title, required this.body, this.drawer, this.appBar, this.floatingActionButton, this.bottomSheet, this.persistentFooterButtons, this.floatingActionButtonLocation, this.bottomNavigationBar, this.actions, super.key, }); @override ConsumerState createState() => _BasicPageState(); } class _BasicPageState extends ConsumerState { @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: widget.bottomNavigationBar, appBar: widget.appBar ?? AppBar( title: Row( children: [ Text(widget.title ?? "myLog"), // Switch( // activeColor: Colors.orange, // onChanged: (value) { // ref.read(appThemeProvider.notifier).state = value; // }, // value: isDarkMode) ], ), actions: [ ...widget.actions ?? [], if (ref.watch(isLoadingProvider)) const Padding( padding: EdgeInsets.all(10), child: CircularProgressIndicator()) ], ), body: widget.body, drawer: widget.drawer ?? const NavDrawer(), floatingActionButton: widget.floatingActionButton, floatingActionButtonLocation: widget.floatingActionButtonLocation, bottomSheet: widget.bottomSheet, persistentFooterButtons: widget.persistentFooterButtons, ); } } final isLoadingProvider = StateProvider( // We return the default sort type, here name. (ref) => false, );