| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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<Widget>? persistentFooterButtons;
- final dynamic floatingActionButtonLocation;
- final Widget? bottomNavigationBar;
- final List<Widget>? 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<ConsumerStatefulWidget> createState() => _BasicPageState();
- }
- class _BasicPageState extends ConsumerState<BasicPage> {
- @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<bool>(
- // We return the default sort type, here name.
- (ref) => false,
- );
|