63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../../app.dart';
|
|
|
|
class DashboardController extends GetxController with GetSingleTickerProviderStateMixin {
|
|
late AnimationController animationController;
|
|
var tabIndex = 0.obs;
|
|
|
|
void changeTabIndex(int index) {
|
|
debugPrint('changeTabIndex $index');
|
|
tabIndex.value = index;
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
_init();
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
animationController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
Future<void> _init() async {
|
|
FlutterNativeSplash.remove();
|
|
animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 300), value: 1);
|
|
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
final bool isRemoved = prefs.getBool(Constants.IS_SPLASH_REMOVED) ?? false;
|
|
|
|
if (isRemoved) {
|
|
prefs.setBool(Constants.IS_SPLASH_REMOVED, true);
|
|
} else {
|
|
FlutterNativeSplash.remove();
|
|
}
|
|
}
|
|
|
|
// Hide bottom navbar on scroll down
|
|
/* bool handleScrollNotification(ScrollNotification notification) {
|
|
if (notification.depth == 0) {
|
|
if (notification is UserScrollNotification) {
|
|
final UserScrollNotification userScroll = notification;
|
|
switch (userScroll.direction) {
|
|
case ScrollDirection.forward:
|
|
animationController.forward();
|
|
break;
|
|
case ScrollDirection.reverse:
|
|
animationController.reverse();
|
|
break;
|
|
case ScrollDirection.idle:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
} */
|
|
}
|