-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.dart
145 lines (125 loc) · 4.03 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
// import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:responsive_builder/responsive_builder.dart';
import 'backend/firebase/firebase_config.dart';
import 'flutter_flow/flutter_flow_theme.dart';
import 'flutter_flow/flutter_flow_util.dart';
import 'flutter_flow/internationalization.dart';
import 'home_page/home_page_presenter.dart';
import 'index.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initFirebase();
await FlutterFlowTheme.initialize();
final appState = FFAppState(); // Initialize FFAppState
ResponsiveSizingConfig.instance.setCustomBreakpoints(
ScreenBreakpoints(desktop: 850, tablet: 700, watch: 200),
);
runApp(ChangeNotifierProvider(
create: (context) => appState,
child: MyApp(),
));
}
class MyApp extends StatefulWidget {
// This widget is the root of your application.
@override
State<MyApp> createState() => _MyAppState();
static _MyAppState of(BuildContext context) =>
context.findAncestorStateOfType<_MyAppState>()!;
}
class _MyAppState extends State<MyApp> {
Locale? _locale;
ThemeMode _themeMode = FlutterFlowTheme.themeMode;
late AppStateNotifier _appStateNotifier;
late GoRouter _router;
@override
void initState() {
super.initState();
_appStateNotifier = AppStateNotifier();
_router = createRouter(_appStateNotifier);
}
void setLocale(String language) {
setState(() => _locale = createLocale(language));
}
void setThemeMode(ThemeMode mode) => setState(() {
_themeMode = mode;
FlutterFlowTheme.saveThemeMode(mode);
});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'FlutterFlow responsive WEB showcase',
localizationsDelegates: [
FFLocalizationsDelegate(),
],
locale: _locale,
supportedLocales: const [Locale('en', '')],
theme: ThemeData(brightness: Brightness.light),
darkTheme: ThemeData(brightness: Brightness.dark),
themeMode: _themeMode,
routeInformationParser: _router.routeInformationParser,
routerDelegate: _router.routerDelegate,
);
}
}
class NavBarPage extends StatefulWidget {
NavBarPage({Key? key, this.initialPage, this.page}) : super(key: key);
final String? initialPage;
final Widget? page;
@override
_NavBarPageState createState() => _NavBarPageState();
}
/// This is the private State class that goes with NavBarPage.
class _NavBarPageState extends State<NavBarPage> {
String _currentPageName = 'HomePage';
late Widget? _currentPage;
@override
void initState() {
super.initState();
_currentPageName = widget.initialPage ?? _currentPageName;
_currentPage = widget.page;
}
@override
Widget build(BuildContext context) {
final tabs = {
'HomePage': HomePagePresenter(),
'PROFILE': ProfileWidget(),
};
final currentIndex = tabs.keys.toList().indexOf(_currentPageName);
return Scaffold(
body: _currentPage ?? tabs[_currentPageName],
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentIndex,
onTap: (i) => setState(() {
_currentPage = null;
_currentPageName = tabs.keys.toList()[i];
}),
backgroundColor: FlutterFlowTheme.of(context).primary,
selectedItemColor: FlutterFlowTheme.of(context).lineColor,
unselectedItemColor: FlutterFlowTheme.of(context).noaktive,
showSelectedLabels: false,
showUnselectedLabels: false,
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(
Icons.view_carousel_outlined,
size: 27.0,
),
label: 'Home',
tooltip: '',
),
BottomNavigationBarItem(
icon: Icon(
Icons.settings,
size: 20.0,
),
label: 'Profile',
tooltip: '',
)
],
),
);
}
}