You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.0 KiB
Dart
79 lines
2.0 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart';
|
|
import 'package:uco_mobile_poc/app/modules/dashboard/views/shared/drawer_data.dart';
|
|
import 'package:uco_mobile_poc/app/modules/dashboard/views/shared/home_page.dart';
|
|
|
|
class DashboardScreenView extends StatefulWidget {
|
|
const DashboardScreenView({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<DashboardScreenView> createState() => _DashBoardViewState();
|
|
}
|
|
|
|
class _DashBoardViewState extends State<DashboardScreenView> with SingleTickerProviderStateMixin {
|
|
late AnimationController _animationController;
|
|
|
|
bool _isDoubleTapped = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_animationController = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(milliseconds: 200),
|
|
);
|
|
}
|
|
|
|
void toggleAnimation() {
|
|
_animationController.isDismissed ? _animationController.forward() : _animationController.reverse();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_animationController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
Future<bool> handleDoubleTab() async {
|
|
if (_isDoubleTapped) {
|
|
return true; // Allow the app to be exited
|
|
} else {
|
|
// Set _isDoubleTapped to true and display a message
|
|
setState(() {
|
|
_isDoubleTapped = true;
|
|
});
|
|
// Reset _isDoubleTapped after 2 seconds
|
|
Timer(const Duration(seconds: 2), () {
|
|
setState(() {
|
|
_isDoubleTapped = false;
|
|
});
|
|
});
|
|
// Prevent the app from being exited
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return WillPopScope(
|
|
onWillPop: () => handleDoubleTab(),
|
|
child: SafeArea(
|
|
child: Material(
|
|
child: ZoomDrawer(
|
|
menuScreen: DrawerData(),
|
|
mainScreen: MyHomePage(),
|
|
borderRadius: 24.0,
|
|
showShadow: true,
|
|
angle: 0.0,
|
|
openCurve: Curves.fastOutSlowIn,
|
|
closeCurve: Curves.easeInBack,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|