implemented post-login splash screen with Lottie animations and integrated background data prefetching during the login transition

This commit is contained in:
MineTec committed 2026-06-29 12:00:26 +02:00
1 parent 13f4f79829
commit 4bc7ffd37a
6 files changed
+256 -40

No files matched your search

+1
View File
@@ -0,0 +1 @@
{"v":"5.7.0","fr":60,"ip":0,"op":185,"w":512,"h":600,"nm":"Logo M Build","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Logo","sr":1,"ks":{"o":{"a":1,"k":[{"t":0,"s":[0],"i":{"x":[0.33],"y":[1]},"o":{"x":[0.66],"y":[0]}},{"t":14,"s":[100]}]},"r":{"a":0,"k":0},"p":{"a":0,"k":[256,300,0]},"a":{"a":0,"k":[47.91499999999999,55.94999999999996,0]},"s":{"a":0,"k":[360,360,100]}},"shapes":[{"ty":"gr","nm":"Fill grp","it":[{"ty":"sh","ind":0,"ix":1,"nm":"M","ks":{"a":0,"k":{"c":true,"v":[[44.72,2.14],[42.6,16.33],[53.400000000000006,18.45],[62.09,22.48],[52.980000000000004,24.6],[41.75,22.48],[39.84,31.17],[34.760000000000005,57.870000000000005],[36.88,54.690000000000005],[47.900000000000006,37.53],[53.620000000000005,32.02],[61.88,37.74],[60.18,51.09],[58.49,64.44],[70.14,46.01],[75.86,41.769999999999996],[82,64.64999999999999],[90.47,77.77999999999999],[95.92,79.04999999999998],[89.83,82.00999999999998],[74.78999999999999,54.25999999999998],[72.24999999999999,57.85999999999998],[57.83999999999999,82.21999999999997],[51.26999999999999,86.24999999999997],[48.72999999999999,83.49999999999997],[49.14999999999999,73.53999999999996],[52.959999999999994,45.14999999999996],[50.209999999999994,47.47999999999996],[44.06999999999999,57.859999999999964],[36.43999999999999,72.04999999999997],[24.72999999999999,104.87999999999997],[23.45999999999999,109.11999999999996],[21.76999999999999,112.71999999999996],[18.37999999999999,102.75999999999996],[28.60999999999999,57.00999999999996],[14.629999999999988,68.44999999999996],[1.4899999999999878,62.51999999999996],[0.21999999999998776,58.70999999999996],[9.749999999999988,62.30999999999996],[13.349999999999987,61.88999999999996],[27.759999999999987,45.14999999999996],[34.95999999999999,21.419999999999963],[24.359999999999985,19.649999999999963],[14.619999999999985,16.759999999999962],[18.009999999999984,12.729999999999961],[36.01999999999998,15.479999999999961],[39.61999999999998,0.4399999999999622]],"i":[[-0.8000000000000185,-1.290000000000038],[0.6799999999999997,-4.519999999999998],[-4.100000000000001,-0.7900000000000027],[-0.21999999999999886,-3.0400000000000027],[3.0799999999999983,0.5599999999999987],[3.530000000000001,0.7200000000000024],[0.6099999999999994,-2.950000000000003],[1.519999999999996,-8.89],[-0.6299999999999955,1.1099999999999994],[-4.230000000000004,5.310000000000002],[-2,0.9299999999999997],[-0.19999999999999574,-4.649999999999999],[0.5800000000000054,-4.590000000000003],[0.5799999999999983,-3.9199999999999946],[-4.5,5.390000000000001],[-2.1599999999999966,0.3400000000000034],[-0.01999999999999602,-7.779999999999994],[-6.340000000000003,-0.7800000000000011],[-0.3299999999999983,-1.8100000000000023],[2.3100000000000023,-0.029999999999986926],[-0.539999999999992,15.060000000000002],[0.8100000000000023,-1.3000000000000043],[4.549999999999997,-8.539999999999992],[3.969999999999999,1.519999999999996],[0.21000000000000085,0.5999999999999943],[-0.3500000000000014,3.3100000000000023],[-1.0100000000000051,9.57],[0.6300000000000026,-0.8799999999999955],[1.980000000000004,-3.5700000000000003],[2.3999999999999986,-4.859999999999999],[2.5900000000000034,-8.560000000000002],[0.41000000000000014,-1.4299999999999926],[1.1900000000000013,-0.8099999999999881],[-0.9499999999999993,4.889999999999986],[-1.9700000000000024,11.579999999999998],[6.530000000000001,-1.4099999999999966],[2.6000000000000014,3.6199999999999974],[-0.73,1.4100000000000037],[-4.049999999999999,-0.45000000000000284],[-0.9599999999999991,0.30000000000000426],[-2.919999999999998,6.159999999999997],[-1.1400000000000006,7.75],[3.6799999999999997,0.6999999999999993],[2.0600000000000005,2.370000000000001],[-1.3900000000000006,1.0900000000000016],[-5.799999999999997,-1.120000000000001],[-1.0900000000000034,4.469999999999999]],"o":[[-0.7899999999999991,5.139999999999999],[4.200000000000003,0.9200000000000017],[3.0900000000000034,0.5899999999999999],[0.3100000000000023,4.48],[-4.079999999999998,-0.7399999999999984],[-0.6599999999999966,2.9400000000000013],[-1.7800000000000011,8.619999999999997],[0.8800000000000026,-1.240000000000002],[3.229999999999997,-5.719999999999999],[1.6199999999999974,-2.030000000000001],[4.759999999999998,-2.1900000000000013],[0.17999999999999972,4.119999999999997],[-0.6000000000000014,4.75],[3.5,-4.969999999999999],[1.3299999999999983,-1.6000000000000014],[10.579999999999998,-1.6599999999999966],[0.01999999999999602,7.010000000000005],[2.0799999999999983,0.2600000000000051],[0.4200000000000017,2.2900000000000063],[-14.090000000000003,0.21999999999999886],[-0.9599999999999937,0.8999999999999986],[-4.719999999999999,7.539999999999999],[-1.25,2.3599999999999994],[-0.8299999999999983,-0.3199999999999932],[-0.9500000000000028,-2.769999999999996],[1.0399999999999991,-9.850000000000001],[-1.2700000000000031,-0.030000000000001137],[-2.270000000000003,3.1599999999999966],[-2.549999999999997,4.600000000000001],[-3.6400000000000006,7.400000000000006],[-0.4200000000000017,1.3900000000000006],Line truncated
+1
View File
@@ -0,0 +1 @@
{"v":"5.7.0","fr":60,"ip":0,"op":185,"w":512,"h":600,"nm":"Logo M Build","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Logo","sr":1,"ks":{"o":{"a":1,"k":[{"t":0,"s":[0],"i":{"x":[0.33],"y":[1]},"o":{"x":[0.66],"y":[0]}},{"t":14,"s":[100]}]},"r":{"a":0,"k":0},"p":{"a":0,"k":[256,300,0]},"a":{"a":0,"k":[47.91499999999999,55.94999999999996,0]},"s":{"a":0,"k":[360,360,100]}},"shapes":[{"ty":"gr","nm":"Fill grp","it":[{"ty":"sh","ind":0,"ix":1,"nm":"M","ks":{"a":0,"k":{"c":true,"v":[[44.72,2.14],[42.6,16.33],[53.400000000000006,18.45],[62.09,22.48],[52.980000000000004,24.6],[41.75,22.48],[39.84,31.17],[34.760000000000005,57.870000000000005],[36.88,54.690000000000005],[47.900000000000006,37.53],[53.620000000000005,32.02],[61.88,37.74],[60.18,51.09],[58.49,64.44],[70.14,46.01],[75.86,41.769999999999996],[82,64.64999999999999],[90.47,77.77999999999999],[95.92,79.04999999999998],[89.83,82.00999999999998],[74.78999999999999,54.25999999999998],[72.24999999999999,57.85999999999998],[57.83999999999999,82.21999999999997],[51.26999999999999,86.24999999999997],[48.72999999999999,83.49999999999997],[49.14999999999999,73.53999999999996],[52.959999999999994,45.14999999999996],[50.209999999999994,47.47999999999996],[44.06999999999999,57.859999999999964],[36.43999999999999,72.04999999999997],[24.72999999999999,104.87999999999997],[23.45999999999999,109.11999999999996],[21.76999999999999,112.71999999999996],[18.37999999999999,102.75999999999996],[28.60999999999999,57.00999999999996],[14.629999999999988,68.44999999999996],[1.4899999999999878,62.51999999999996],[0.21999999999998776,58.70999999999996],[9.749999999999988,62.30999999999996],[13.349999999999987,61.88999999999996],[27.759999999999987,45.14999999999996],[34.95999999999999,21.419999999999963],[24.359999999999985,19.649999999999963],[14.619999999999985,16.759999999999962],[18.009999999999984,12.729999999999961],[36.01999999999998,15.479999999999961],[39.61999999999998,0.4399999999999622]],"i":[[-0.8000000000000185,-1.290000000000038],[0.6799999999999997,-4.519999999999998],[-4.100000000000001,-0.7900000000000027],[-0.21999999999999886,-3.0400000000000027],[3.0799999999999983,0.5599999999999987],[3.530000000000001,0.7200000000000024],[0.6099999999999994,-2.950000000000003],[1.519999999999996,-8.89],[-0.6299999999999955,1.1099999999999994],[-4.230000000000004,5.310000000000002],[-2,0.9299999999999997],[-0.19999999999999574,-4.649999999999999],[0.5800000000000054,-4.590000000000003],[0.5799999999999983,-3.9199999999999946],[-4.5,5.390000000000001],[-2.1599999999999966,0.3400000000000034],[-0.01999999999999602,-7.779999999999994],[-6.340000000000003,-0.7800000000000011],[-0.3299999999999983,-1.8100000000000023],[2.3100000000000023,-0.029999999999986926],[-0.539999999999992,15.060000000000002],[0.8100000000000023,-1.3000000000000043],[4.549999999999997,-8.539999999999992],[3.969999999999999,1.519999999999996],[0.21000000000000085,0.5999999999999943],[-0.3500000000000014,3.3100000000000023],[-1.0100000000000051,9.57],[0.6300000000000026,-0.8799999999999955],[1.980000000000004,-3.5700000000000003],[2.3999999999999986,-4.859999999999999],[2.5900000000000034,-8.560000000000002],[0.41000000000000014,-1.4299999999999926],[1.1900000000000013,-0.8099999999999881],[-0.9499999999999993,4.889999999999986],[-1.9700000000000024,11.579999999999998],[6.530000000000001,-1.4099999999999966],[2.6000000000000014,3.6199999999999974],[-0.73,1.4100000000000037],[-4.049999999999999,-0.45000000000000284],[-0.9599999999999991,0.30000000000000426],[-2.919999999999998,6.159999999999997],[-1.1400000000000006,7.75],[3.6799999999999997,0.6999999999999993],[2.0600000000000005,2.370000000000001],[-1.3900000000000006,1.0900000000000016],[-5.799999999999997,-1.120000000000001],[-1.0900000000000034,4.469999999999999]],"o":[[-0.7899999999999991,5.139999999999999],[4.200000000000003,0.9200000000000017],[3.0900000000000034,0.5899999999999999],[0.3100000000000023,4.48],[-4.079999999999998,-0.7399999999999984],[-0.6599999999999966,2.9400000000000013],[-1.7800000000000011,8.619999999999997],[0.8800000000000026,-1.240000000000002],[3.229999999999997,-5.719999999999999],[1.6199999999999974,-2.030000000000001],[4.759999999999998,-2.1900000000000013],[0.17999999999999972,4.119999999999997],[-0.6000000000000014,4.75],[3.5,-4.969999999999999],[1.3299999999999983,-1.6000000000000014],[10.579999999999998,-1.6599999999999966],[0.01999999999999602,7.010000000000005],[2.0799999999999983,0.2600000000000051],[0.4200000000000017,2.2900000000000063],[-14.090000000000003,0.21999999999999886],[-0.9599999999999937,0.8999999999999986],[-4.719999999999999,7.539999999999999],[-1.25,2.3599999999999994],[-0.8299999999999983,-0.3199999999999932],[-0.9500000000000028,-2.769999999999996],[1.0399999999999991,-9.850000000000001],[-1.2700000000000031,-0.030000000000001137],[-2.270000000000003,3.1599999999999966],[-2.549999999999997,4.600000000000001],[-3.6400000000000006,7.400000000000006],[-0.4200000000000017,1.3900000000000006],Line truncated
+29 -1
View File
@@ -41,6 +41,7 @@ import 'theming/dark_app_theme.dart';
import 'theming/light_app_theme.dart';
import 'utils/app_paths.dart';
import 'view/login/login.dart';
import 'view/login/post_login_splash.dart';
import 'widget/app_progress_indicator.dart';
import 'widget/breaker/breaker.dart';
import 'widget/debug/cache_view.dart';
@@ -188,6 +189,9 @@ class Main extends StatefulWidget {
}
class _MainState extends State<Main> {
bool _showPostLoginSplash = false;
bool _appMounted = true;
@override
void initState() {
super.initState();
@@ -215,6 +219,12 @@ class _MainState extends State<Main> {
/// password has been rotated server-side; the validator wipes the local
/// session and we flip the account bloc back to `loggedOut`, which sends
/// the user to the login screen.
void _prefetchBaseData(BuildContext context) {
context.read<TimetableBloc>().refresh();
unawaited(context.read<ChatListBloc>().refresh(silent: true));
unawaited(ListFilesCache.prefetchRootListing());
}
void _scheduleSessionValidation(AccountBloc accountBloc) {
unawaited(
SessionValidator.probeStored(
@@ -282,6 +292,12 @@ class _MainState extends State<Main> {
unawaited(
context.read<NextcloudCapabilitiesCubit>().load(),
);
_showPostLoginSplash = true;
_appMounted = false;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) setState(() => _appMounted = true);
});
_prefetchBaseData(context);
}
if (accountState.status != AccountStatus.loggedOut) return;
// A pending share would otherwise survive logout and be
@@ -328,7 +344,19 @@ class _MainState extends State<Main> {
builder: (context, accountState) {
switch (accountState.status) {
case AccountStatus.loggedIn:
return const App();
return Stack(
fit: StackFit.expand,
children: [
if (_appMounted) const App(key: ValueKey('app-shell')),
if (_showPostLoginSplash)
PostLoginSplash(
key: const ValueKey('post-login-splash'),
onComplete: () => setState(
() => _showPostLoginSplash = false,
),
),
],
);
case AccountStatus.loggedOut:
return const Login();
case AccountStatus.undefined:
+56 -39
View File
@@ -13,6 +13,7 @@ import '../../theming/light_app_theme.dart';
import '../../utils/haptics.dart';
import '../pages/settings/widgets/endpoint_picker.dart';
import 'login_controller.dart';
import 'post_login_splash.dart';
import 'widgets/login_branding.dart';
import 'widgets/login_card.dart';
@@ -23,73 +24,89 @@ class Login extends StatefulWidget {
State<Login> createState() => _LoginState();
}
class _LoginState extends State<Login> {
class _LoginState extends State<Login> with SingleTickerProviderStateMixin {
static const _marianumRed = LightAppTheme.marianumRed;
final LoginController _controller = LoginController();
late final AnimationController _fade = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 450),
value: 1,
);
@override
void didChangeDependencies() {
super.didChangeDependencies();
precacheImage(const AssetImage('assets/logo/icon.png'), context);
unawaited(PostLoginSplash.precache());
}
@override
void dispose() {
_fade.dispose();
_controller.dispose();
super.dispose();
}
void _onLoginSuccess() {
Haptics.heavyAccent();
context.read<AccountBloc>().setStatus(AccountStatus.loggedIn);
// Re-register the periodic refresh (cancelAll runs on logout) and kick
// off an immediate one-off so the widget populates within seconds
// instead of waiting up to 30 minutes for the next periodic slot.
unawaited(WidgetBackgroundTask.initialize());
unawaited(WidgetBackgroundTask.requestImmediateRefresh());
// Fade the login content out before handing over to the post-login splash.
// Both share the red backdrop, so this reads as one continuous transition
// instead of an abrupt swap.
_fade.reverse().whenComplete(() {
if (!mounted) return;
context.read<AccountBloc>().setStatus(AccountStatus.loggedIn);
});
}
@override
Widget build(BuildContext context) => Scaffold(
backgroundColor: _marianumRed,
body: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
maxWidth: 420,
),
// spaceBetween statt Spacer-in-IntrinsicHeight: bei jeder
// Inhaltsänderung im unteren Block (z.B. EndpointLink mit
// dynamischem Label) würde IntrinsicHeight sonst die Column
// an die intrinsic-Höhe pinnen und ein paar Pixel Overflow
// produzieren. spaceBetween fügt nur den verbleibenden Gap
// ein und schrumpft sauber auf 0, wenn der Inhalt zu hoch
// wird — dann übernimmt der äußere ScrollView.
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
const LoginHeader(),
const SizedBox(height: 28),
LoginCard(
controller: _controller,
onSuccess: _onLoginSuccess,
),
const SizedBox(height: 18),
const LoginDisclaimer(),
],
),
const Column(
mainAxisSize: MainAxisSize.min,
children: [_EndpointLink(), LoginFooter()],
),
],
body: FadeTransition(
opacity: _fade,
child: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
maxWidth: 420,
),
// spaceBetween statt Spacer-in-IntrinsicHeight: bei jeder
// Inhaltsänderung im unteren Block (z.B. EndpointLink mit
// dynamischem Label) würde IntrinsicHeight sonst die Column
// an die intrinsic-Höhe pinnen und ein paar Pixel Overflow
// produzieren. spaceBetween fügt nur den verbleibenden Gap
// ein und schrumpft sauber auf 0, wenn der Inhalt zu hoch
// wird — dann übernimmt der äußere ScrollView.
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
const LoginHeader(),
const SizedBox(height: 28),
LoginCard(
controller: _controller,
onSuccess: _onLoginSuccess,
),
const SizedBox(height: 18),
const LoginDisclaimer(),
],
),
const Column(
mainAxisSize: MainAxisSize.min,
children: [_EndpointLink(), LoginFooter()],
),
],
),
),
),
),
+168
View File
@@ -0,0 +1,168 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import '../../theming/app_theme.dart';
import '../../theming/light_app_theme.dart';
class PostLoginSplash extends StatefulWidget {
const PostLoginSplash({super.key, required this.onComplete});
static const String _darkAsset = 'assets/logo/logo-anim-white.json';
static const String _lightAsset = 'assets/logo/logo-anim-red.json';
static LottieComposition? _darkComposition;
static LottieComposition? _lightComposition;
static Future<void> precache() async {
try {
_darkComposition ??= await AssetLottie(_darkAsset).load();
_lightComposition ??= await AssetLottie(_lightAsset).load();
} catch (_) {}
}
final VoidCallback onComplete;
@override
State<PostLoginSplash> createState() => _PostLoginSplashState();
}
class _PostLoginSplashState extends State<PostLoginSplash>
with TickerProviderStateMixin {
static const Duration _holdAfterLogo = Duration(milliseconds: 450);
late final AnimationController _intro;
late final AnimationController _outro;
late final AnimationController _logo;
late final Animation<double> _introCurve;
late final Animation<double> _outroCurve;
Timer? _safety;
Timer? _hold;
LottieComposition? _composition;
bool _started = false;
bool _outroStarted = false;
bool _completed = false;
@override
void initState() {
super.initState();
_intro = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 900),
);
_outro = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 850),
);
_introCurve = CurvedAnimation(parent: _intro, curve: Curves.easeInOut);
_outroCurve = CurvedAnimation(parent: _outro, curve: Curves.easeInOutCubic);
_logo = AnimationController(vsync: this);
_logo.addStatusListener((status) {
if (status == AnimationStatus.completed) _scheduleOutro();
});
_safety = Timer(const Duration(seconds: 6), _startOutro);
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (_started || _outroStarted) return;
final isDark = AppTheme.isDarkMode(context);
final cached = isDark
? PostLoginSplash._darkComposition
: PostLoginSplash._lightComposition;
if (cached != null) {
_begin(cached);
return;
}
final asset = isDark
? PostLoginSplash._darkAsset
: PostLoginSplash._lightAsset;
AssetLottie(asset)
.load()
.then((c) {
if (mounted) _begin(c);
})
.catchError((_) {});
}
void _begin(LottieComposition composition) {
if (_started || _outroStarted || !mounted) return;
_started = true;
_logo.duration = composition.duration * 0.9;
setState(() => _composition = composition);
_intro.forward(from: 0);
_logo.forward(from: 0);
}
void _scheduleOutro() {
if (_outroStarted || _hold != null) return;
_hold = Timer(_holdAfterLogo, _startOutro);
}
void _startOutro() {
if (_outroStarted) return;
_outroStarted = true;
_safety?.cancel();
_hold?.cancel();
_outro.forward().whenComplete(() {
if (_completed || !mounted) return;
_completed = true;
widget.onComplete();
});
}
@override
void dispose() {
_safety?.cancel();
_hold?.cancel();
_intro.dispose();
_outro.dispose();
_logo.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final surface = Theme.of(context).scaffoldBackgroundColor;
return AbsorbPointer(
child: AnimatedBuilder(
animation: Listenable.merge([_introCurve, _outroCurve]),
builder: (context, _) {
final intro = _introCurve.value;
final outro = _outroCurve.value;
final background = Color.lerp(
LightAppTheme.marianumRed,
surface,
intro,
);
return Opacity(
opacity: 1 - outro,
child: ColoredBox(
color: background ?? surface,
child: Center(
child: _composition == null
? const SizedBox.shrink()
: Opacity(
opacity: intro,
child: Transform.scale(
scale: (0.94 + 0.06 * intro) * (1 + 0.05 * outro),
child: Lottie(
composition: _composition,
controller: _logo,
width: 220,
height: 220,
fit: BoxFit.contain,
),
),
),
),
),
);
},
),
);
}
}
+1
View File
@@ -58,6 +58,7 @@ dependencies:
json_annotation: ^4.9.0
loader_overlay: ^5.0.0
localstore: ^1.4.0
lottie: ^3.4.0
nextcloud:
git:
path: packages/nextcloud