rluv_client/lib/main.dart

70 lines
1.6 KiB
Dart
Raw Normal View History

2023-07-15 17:23:27 -06:00
import 'package:flutter/material.dart';
2023-07-19 02:16:13 -06:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:rluv/features/budget/screens/budget_overview.dart';
import 'package:rluv/global/styles.dart';
2023-07-15 17:23:27 -06:00
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
2023-07-19 02:16:13 -06:00
return ProviderScope(
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const Home(),
2023-07-15 17:23:27 -06:00
),
);
}
}
2023-07-19 02:16:13 -06:00
class Home extends ConsumerStatefulWidget {
const Home({super.key});
2023-07-15 17:23:27 -06:00
@override
2023-07-19 02:16:13 -06:00
ConsumerState<Home> createState() => _HomeState();
2023-07-15 17:23:27 -06:00
}
2023-07-19 02:16:13 -06:00
class _HomeState extends ConsumerState<Home> {
2023-07-15 17:23:27 -06:00
@override
Widget build(BuildContext context) {
return Scaffold(
2023-07-19 02:16:13 -06:00
resizeToAvoidBottomInset: false,
drawer: const Drawer(
backgroundColor: Styles.purpleNurple,
2023-07-15 17:23:27 -06:00
),
2023-07-19 02:16:13 -06:00
appBar: AppBar(
backgroundColor: Styles.purpleNurple,
title: Text(
ref.watch(appBarTitleProvider),
2023-07-15 17:23:27 -06:00
),
),
2023-07-19 02:16:13 -06:00
body: ref.watch(currentHomePageProvider),
2023-07-15 17:23:27 -06:00
);
}
}
2023-07-19 02:16:13 -06:00
final currentHomePageProvider = StateProvider<Widget>(
(ref) => const BudgetOverviewScreen(),
);
final appBarTitleProvider = Provider<String>(
(ref) {
final currentPageName = ref.watch(currentHomePageProvider).toString();
switch (currentPageName) {
case 'BudgetOverviewScreen':
return 'Budget';
default:
return '';
}
},
);