rluv_client/lib/main.dart
2023-07-19 02:16:13 -06:00

70 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:rluv/features/budget/screens/budget_overview.dart';
import 'package:rluv/global/styles.dart';
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) {
return ProviderScope(
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const Home(),
),
);
}
}
class Home extends ConsumerStatefulWidget {
const Home({super.key});
@override
ConsumerState<Home> createState() => _HomeState();
}
class _HomeState extends ConsumerState<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
drawer: const Drawer(
backgroundColor: Styles.purpleNurple,
),
appBar: AppBar(
backgroundColor: Styles.purpleNurple,
title: Text(
ref.watch(appBarTitleProvider),
),
),
body: ref.watch(currentHomePageProvider),
);
}
}
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 '';
}
},
);