61 lines
1.8 KiB
Dart
61 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:hive/hive.dart';
|
|
import 'package:pilipala/pages/dynamics/index.dart';
|
|
import 'package:pilipala/pages/home/index.dart';
|
|
import 'package:pilipala/pages/home/widgets/left_drawer.dart';
|
|
import 'package:pilipala/pages/media/index.dart';
|
|
import 'package:pilipala/utils/event_bus.dart';
|
|
import 'package:pilipala/utils/feed_back.dart';
|
|
import 'package:pilipala/utils/storage.dart';
|
|
import './controller.dart';
|
|
|
|
class MainApp extends StatefulWidget {
|
|
const MainApp({super.key});
|
|
|
|
@override
|
|
State<MainApp> createState() => _MainAppState();
|
|
}
|
|
|
|
class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|
final MainController _mainController = Get.put(MainController());
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
int selectedIndex = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
void openDrawer() {
|
|
_scaffoldKey.currentState?.openDrawer();
|
|
}
|
|
|
|
@override
|
|
void dispose() async {
|
|
await GStrorage.close();
|
|
EventBus().off(EventName.loginEvent);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Box localCache = GStrorage.localCache;
|
|
double statusBarHeight = MediaQuery.of(context).padding.top;
|
|
double sheetHeight = MediaQuery.of(context).size.height -
|
|
MediaQuery.of(context).padding.top -
|
|
MediaQuery.of(context).size.width * 9 / 16;
|
|
localCache.put('sheetHeight', sheetHeight);
|
|
localCache.put('statusBarHeight', statusBarHeight);
|
|
return WillPopScope(
|
|
onWillPop: () => _mainController.onBackPressed(context),
|
|
child: Scaffold(
|
|
key: _scaffoldKey,
|
|
extendBody: true,
|
|
drawer: const LeftDrawer(),
|
|
body: HomePage(callFn: openDrawer),
|
|
),
|
|
);
|
|
}
|
|
}
|