Files
UVita---An-Application-Prot…/Application Product/Source/source/lib/main.dart

245 lines
7.3 KiB
Dart
Executable File

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import 'flutter_flow/flutter_flow_util.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:floating_bottom_navigation_bar/floating_bottom_navigation_bar.dart';
import 'flutter_flow/nav/nav.dart';
import 'index.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
GoRouter.optionURLReflectsImperativeAPIs = true;
usePathUrlStrategy();
await FlutterFlowTheme.initialize();
runApp(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> {
ThemeMode _themeMode = FlutterFlowTheme.themeMode;
late AppStateNotifier _appStateNotifier;
late GoRouter _router;
bool displaySplashImage = true;
@override
void initState() {
super.initState();
_appStateNotifier = AppStateNotifier.instance;
_router = createRouter(_appStateNotifier);
Future.delayed(Duration(milliseconds: 1000),
() => safeSetState(() => _appStateNotifier.stopShowingSplashImage()));
}
void setThemeMode(ThemeMode mode) => safeSetState(() {
_themeMode = mode;
FlutterFlowTheme.saveThemeMode(mode);
});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'UVita',
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale('en', '')],
theme: ThemeData(
brightness: Brightness.light,
useMaterial3: false,
),
darkTheme: ThemeData(
brightness: Brightness.dark,
useMaterial3: false,
),
themeMode: _themeMode,
routerConfig: _router,
);
}
}
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': HomePageWidget(),
'Analyst': AnalystWidget(),
'Infomation': InfomationWidget(),
'setting': SettingWidget(),
'NEWS': NewsWidget(),
};
final currentIndex = tabs.keys.toList().indexOf(_currentPageName);
final MediaQueryData queryData = MediaQuery.of(context);
return Scaffold(
body: MediaQuery(
data: queryData
.removeViewInsets(removeBottom: true)
.removeViewPadding(removeBottom: true),
child: _currentPage ?? tabs[_currentPageName]!),
extendBody: true,
bottomNavigationBar: FloatingNavbar(
currentIndex: currentIndex,
onTap: (i) => safeSetState(() {
_currentPage = null;
_currentPageName = tabs.keys.toList()[i];
}),
backgroundColor: Color(0xD5AB0C0C),
selectedItemColor: Color(0x9EFFF8F8),
unselectedItemColor: Colors.white,
selectedBackgroundColor: Color(0x00000000),
borderRadius: 8.0,
itemBorderRadius: 8.0,
margin: EdgeInsets.all(12.0),
padding: EdgeInsets.all(2.0),
width: double.infinity,
elevation: 0.0,
items: [
FloatingNavbarItem(
customWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.home_outlined,
color: currentIndex == 0 ? Color(0x9EFFF8F8) : Colors.white,
size: 24.0,
),
Text(
'Home',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: currentIndex == 0 ? Color(0x9EFFF8F8) : Colors.white,
fontSize: 11.0,
),
),
],
),
),
FloatingNavbarItem(
customWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.pie_chart,
color: currentIndex == 1 ? Color(0x9EFFF8F8) : Colors.white,
size: 24.0,
),
Text(
'Analyst',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: currentIndex == 1 ? Color(0x9EFFF8F8) : Colors.white,
fontSize: 11.0,
),
),
],
),
),
FloatingNavbarItem(
customWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.info,
color: currentIndex == 2 ? Color(0x9EFFF8F8) : Colors.white,
size: 24.0,
),
Text(
'Infomations',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: currentIndex == 2 ? Color(0x9EFFF8F8) : Colors.white,
fontSize: 11.0,
),
),
],
),
),
FloatingNavbarItem(
customWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.settings_sharp,
color: currentIndex == 3 ? Color(0x9EFFF8F8) : Colors.white,
size: 24.0,
),
Text(
'Settings',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: currentIndex == 3 ? Color(0x9EFFF8F8) : Colors.white,
fontSize: 11.0,
),
),
],
),
),
FloatingNavbarItem(
customWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
FontAwesomeIcons.solidNewspaper,
color: currentIndex == 4 ? Color(0x9EFFF8F8) : Colors.white,
size: 24.0,
),
Text(
'News',
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: currentIndex == 4 ? Color(0x9EFFF8F8) : Colors.white,
fontSize: 11.0,
),
),
],
),
)
],
),
);
}
}