fix: Fixed threshold and added instant load page
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:example/group_info_screen.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:lottie/lottie.dart';
|
import 'package:lottie/lottie.dart';
|
||||||
@@ -102,11 +103,12 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
var now = DateTime.now().millisecondsSinceEpoch;
|
var now = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
|
||||||
if (now - timeOfStartMs > 1000) {
|
if (now - timeOfStartMs > 1500) {
|
||||||
_animationController.forward();
|
SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
|
_animationController.forward();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
var diff = 1000 - (now - timeOfStartMs);
|
Future.delayed(Duration(milliseconds: 1500)).then((value) {
|
||||||
Future.delayed(Duration(milliseconds: diff)).then((value) {
|
|
||||||
_animationController.forward();
|
_animationController.forward();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -137,7 +139,7 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
|||||||
color: _colorAnimation == null
|
color: _colorAnimation == null
|
||||||
? Color(0xff005FFF)
|
? Color(0xff005FFF)
|
||||||
: _colorAnimation.value,
|
: _colorAnimation.value,
|
||||||
child: _initData == null
|
child: !_animationController.isAnimating
|
||||||
? Lottie.asset(
|
? Lottie.asset(
|
||||||
'assets/floating_boat.json',
|
'assets/floating_boat.json',
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -145,24 +147,23 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
|||||||
: Container(),
|
: Container(),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
if (_initData != null)
|
AnimatedBuilder(
|
||||||
AnimatedBuilder(
|
animation: _animation,
|
||||||
animation: _animation,
|
builder: (context, snapshot) {
|
||||||
builder: (context, snapshot) {
|
return Transform.scale(
|
||||||
return Transform.scale(
|
scale: _animation.value,
|
||||||
scale: _animation.value,
|
child: Container(
|
||||||
child: Container(
|
width: 1.0,
|
||||||
width: 1.0,
|
height: 1.0,
|
||||||
height: 1.0,
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: Colors.white
|
||||||
color: Colors.white
|
.withOpacity(1 - _animationController.value),
|
||||||
.withOpacity(1 - _animationController.value),
|
shape: BoxShape.circle,
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -170,48 +171,51 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_initData == null || !_animCompleted) {
|
return Stack(
|
||||||
return _buildAnimation();
|
alignment: Alignment.center,
|
||||||
}
|
children: [
|
||||||
|
if (_initData != null)
|
||||||
return PreferenceBuilder<int>(
|
PreferenceBuilder<int>(
|
||||||
preference: _initData.preferences.getInt(
|
preference: _initData.preferences.getInt(
|
||||||
'theme',
|
'theme',
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
),
|
|
||||||
builder: (context, snapshot) => MaterialApp(
|
|
||||||
builder: (context, child) {
|
|
||||||
return StreamChat(
|
|
||||||
client: _initData.client,
|
|
||||||
onBackgroundEventReceived: (e) =>
|
|
||||||
showLocalNotification(e, _initData.client.state.user.id),
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) => AnnotatedRegion<SystemUiOverlayStyle>(
|
|
||||||
child: child,
|
|
||||||
value: SystemUiOverlayStyle(
|
|
||||||
systemNavigationBarColor:
|
|
||||||
StreamChatTheme.of(context).colorTheme.white,
|
|
||||||
systemNavigationBarIconBrightness:
|
|
||||||
Theme.of(context).brightness == Brightness.dark
|
|
||||||
? Brightness.light
|
|
||||||
: Brightness.dark,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
builder: (context, snapshot) => MaterialApp(
|
||||||
},
|
builder: (context, child) {
|
||||||
theme: ThemeData.light(),
|
return StreamChat(
|
||||||
darkTheme: ThemeData.dark(),
|
client: _initData.client,
|
||||||
themeMode: {
|
onBackgroundEventReceived: (e) =>
|
||||||
-1: ThemeMode.dark,
|
showLocalNotification(e, _initData.client.state.user.id),
|
||||||
0: ThemeMode.system,
|
child: Builder(
|
||||||
1: ThemeMode.light,
|
builder: (context) => AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
}[snapshot],
|
child: child,
|
||||||
onGenerateRoute: AppRoutes.generateRoute,
|
value: SystemUiOverlayStyle(
|
||||||
initialRoute: _initData.client.state.user == null
|
systemNavigationBarColor:
|
||||||
? Routes.CHOOSE_USER
|
StreamChatTheme.of(context).colorTheme.white,
|
||||||
: Routes.HOME,
|
systemNavigationBarIconBrightness:
|
||||||
),
|
Theme.of(context).brightness == Brightness.dark
|
||||||
|
? Brightness.light
|
||||||
|
: Brightness.dark,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
theme: ThemeData.light(),
|
||||||
|
darkTheme: ThemeData.dark(),
|
||||||
|
themeMode: {
|
||||||
|
-1: ThemeMode.dark,
|
||||||
|
0: ThemeMode.system,
|
||||||
|
1: ThemeMode.light,
|
||||||
|
}[snapshot],
|
||||||
|
onGenerateRoute: AppRoutes.generateRoute,
|
||||||
|
initialRoute: _initData.client.state.user == null
|
||||||
|
? Routes.CHOOSE_USER
|
||||||
|
: Routes.HOME,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!_animCompleted) _buildAnimation(),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user