|
|
@ -9,6 +9,7 @@ import 'package:lottie/lottie.dart';
|
|
|
|
import 'package:zoom_tap_animation/zoom_tap_animation.dart';
|
|
|
|
import 'package:zoom_tap_animation/zoom_tap_animation.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../config/routes.dart';
|
|
|
|
import '../config/routes.dart';
|
|
|
|
|
|
|
|
import 'package:timezone/timezone.dart' as tz;
|
|
|
|
import '../main.dart';
|
|
|
|
import '../main.dart';
|
|
|
|
import '../values/constants.dart';
|
|
|
|
import '../values/constants.dart';
|
|
|
|
|
|
|
|
|
|
|
@ -22,7 +23,7 @@ class TopNavBarComponent extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
class _TopNavBarComponentState extends State<TopNavBarComponent> with TickerProviderStateMixin {
|
|
|
|
class _TopNavBarComponentState extends State<TopNavBarComponent> with TickerProviderStateMixin {
|
|
|
|
bool choice = true;
|
|
|
|
bool choice = true;
|
|
|
|
late AnimationController _controller;
|
|
|
|
|
|
|
|
bool isDismissed = true;
|
|
|
|
bool isDismissed = true;
|
|
|
|
|
|
|
|
|
|
|
|
final DateTime midnight = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 1);
|
|
|
|
final DateTime midnight = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 1);
|
|
|
@ -35,90 +36,100 @@ class _TopNavBarComponentState extends State<TopNavBarComponent> with TickerProv
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
_controller = AnimationController(
|
|
|
|
|
|
|
|
vsync: this,
|
|
|
|
|
|
|
|
duration: Duration(seconds: 3),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void showCapsuleDot(bool isAvailable) {
|
|
|
|
Future<void> showCapsuleDot() async {
|
|
|
|
isAvailable
|
|
|
|
// Get the timezone for France
|
|
|
|
? Flushbar(
|
|
|
|
final franceTimeZone = tz.getLocation('Europe/Paris');
|
|
|
|
maxWidth: 210,
|
|
|
|
|
|
|
|
animationDuration: Duration(seconds: 1),
|
|
|
|
// Get the current date and time in France timezone
|
|
|
|
forwardAnimationCurve: Curves.easeOutCirc,
|
|
|
|
var now = tz.TZDateTime.now(franceTimeZone);
|
|
|
|
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
|
|
|
|
icon: Icon(
|
|
|
|
// Calculate the midnight time for the next day in France timezone
|
|
|
|
Ionicons.sparkles,
|
|
|
|
var midnight = tz.TZDateTime(franceTimeZone, now.year, now.month, now.day + 1);
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
|
|
size: 18,
|
|
|
|
bool res = await MyApp.postViewModel.getAvailable();
|
|
|
|
),
|
|
|
|
if (res) {
|
|
|
|
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
|
|
Flushbar(
|
|
|
|
messageText: Align(
|
|
|
|
maxWidth: 210,
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
animationDuration: Duration(seconds: 1),
|
|
|
|
child: Text(
|
|
|
|
forwardAnimationCurve: Curves.easeOutCirc,
|
|
|
|
"Capsule disponible",
|
|
|
|
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
style: GoogleFonts.plusJakartaSans(color: Colors.grey, fontSize: 15),
|
|
|
|
icon: Icon(
|
|
|
|
),
|
|
|
|
Ionicons.sparkles,
|
|
|
|
),
|
|
|
|
color: Colors.white,
|
|
|
|
flushbarStyle: FlushbarStyle.FLOATING,
|
|
|
|
size: 18,
|
|
|
|
flushbarPosition: FlushbarPosition.BOTTOM,
|
|
|
|
),
|
|
|
|
textDirection: Directionality.of(context),
|
|
|
|
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
|
|
borderRadius: BorderRadius.circular(1000),
|
|
|
|
messageText: Align(
|
|
|
|
borderWidth: 1,
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
borderColor: Colors.white.withOpacity(0.04),
|
|
|
|
child: Text(
|
|
|
|
duration: const Duration(minutes: 100),
|
|
|
|
"Capsule disponible",
|
|
|
|
leftBarIndicatorColor: Colors.transparent,
|
|
|
|
style: GoogleFonts.plusJakartaSans(color: Colors.grey, fontSize: 15),
|
|
|
|
positionOffset: 20,
|
|
|
|
),
|
|
|
|
onTap: (_) {
|
|
|
|
),
|
|
|
|
Navigator.pop(context);
|
|
|
|
flushbarStyle: FlushbarStyle.FLOATING,
|
|
|
|
Navigator.pushNamed(context, '/post');
|
|
|
|
flushbarPosition: FlushbarPosition.BOTTOM,
|
|
|
|
},
|
|
|
|
textDirection: Directionality.of(context),
|
|
|
|
).show(context)
|
|
|
|
borderRadius: BorderRadius.circular(1000),
|
|
|
|
: Flushbar(
|
|
|
|
borderWidth: 1,
|
|
|
|
maxWidth: 155,
|
|
|
|
borderColor: Colors.white.withOpacity(0.04),
|
|
|
|
animationDuration: Duration(seconds: 1),
|
|
|
|
duration: const Duration(minutes: 100),
|
|
|
|
forwardAnimationCurve: Curves.easeOutCirc,
|
|
|
|
leftBarIndicatorColor: Colors.transparent,
|
|
|
|
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
positionOffset: 20,
|
|
|
|
icon: Lottie.asset(
|
|
|
|
onTap: (_) {
|
|
|
|
'assets/animations/LottieHourGlass.json',
|
|
|
|
Navigator.pop(context);
|
|
|
|
width: 26,
|
|
|
|
Navigator.pushNamed(context, '/post');
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
).show(context).then((value) {
|
|
|
|
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
|
|
setState(() {
|
|
|
|
messageText: Align(
|
|
|
|
isDismissed = !isDismissed;
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
});
|
|
|
|
child: CountdownTimer(
|
|
|
|
});
|
|
|
|
endTime: midnight.millisecondsSinceEpoch - 2 * 60 * 60 * 1000,
|
|
|
|
} else {
|
|
|
|
textStyle: GoogleFonts.plusJakartaSans(color: Colors.grey, fontSize: 15),
|
|
|
|
Flushbar(
|
|
|
|
),
|
|
|
|
maxWidth: 155,
|
|
|
|
),
|
|
|
|
animationDuration: Duration(seconds: 1),
|
|
|
|
flushbarStyle: FlushbarStyle.FLOATING,
|
|
|
|
forwardAnimationCurve: Curves.easeOutCirc,
|
|
|
|
flushbarPosition: FlushbarPosition.BOTTOM,
|
|
|
|
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
|
|
|
|
textDirection: Directionality.of(context),
|
|
|
|
icon: Lottie.asset(
|
|
|
|
borderRadius: BorderRadius.circular(1000),
|
|
|
|
'assets/animations/LottieHourGlass.json',
|
|
|
|
borderWidth: 1,
|
|
|
|
width: 26,
|
|
|
|
borderColor: Colors.white.withOpacity(0.04),
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
duration: const Duration(minutes: 100),
|
|
|
|
),
|
|
|
|
leftBarIndicatorColor: Colors.transparent,
|
|
|
|
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
|
|
positionOffset: 20,
|
|
|
|
messageText: Align(
|
|
|
|
onTap: (_) {
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
Navigator.pop(context);
|
|
|
|
child: CountdownTimer(
|
|
|
|
},
|
|
|
|
endTime: midnight.millisecondsSinceEpoch,
|
|
|
|
).show(context);
|
|
|
|
textStyle: GoogleFonts.plusJakartaSans(color: Colors.grey, fontSize: 15),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
flushbarStyle: FlushbarStyle.FLOATING,
|
|
|
|
|
|
|
|
flushbarPosition: FlushbarPosition.BOTTOM,
|
|
|
|
|
|
|
|
textDirection: Directionality.of(context),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(1000),
|
|
|
|
|
|
|
|
borderWidth: 1,
|
|
|
|
|
|
|
|
borderColor: Colors.white.withOpacity(0.04),
|
|
|
|
|
|
|
|
duration: const Duration(minutes: 100),
|
|
|
|
|
|
|
|
leftBarIndicatorColor: Colors.transparent,
|
|
|
|
|
|
|
|
positionOffset: 20,
|
|
|
|
|
|
|
|
onTap: (_) {},
|
|
|
|
|
|
|
|
).show(context).then((value) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
isDismissed = !isDismissed;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void checkAvailable() async {
|
|
|
|
void checkAvailable() async {
|
|
|
|
print("test");
|
|
|
|
if (isDismissed) {
|
|
|
|
var res = await MyApp.postViewModel.getAvailable();
|
|
|
|
showCapsuleDot();
|
|
|
|
print(res);
|
|
|
|
setState(() {
|
|
|
|
ModalRoute<dynamic>? route = ModalRoute.of(context);
|
|
|
|
isDismissed = !isDismissed;
|
|
|
|
if (route != null) {
|
|
|
|
});
|
|
|
|
if (route.settings.name != '/flushbarRoute') {
|
|
|
|
|
|
|
|
print("yes");
|
|
|
|
|
|
|
|
showCapsuleDot(res);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|