diff --git a/lib/main.dart b/lib/main.dart index 68e56e1..6b03209 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -74,8 +74,8 @@ class SolianApp extends StatelessWidget { Provider(create: (ctx) => SnAttachmentProvider(ctx)), Provider(create: (ctx) => UserDirectoryProvider(ctx)), ChangeNotifierProvider(create: (ctx) => UserProvider(ctx)), - ChangeNotifierProvider(create: (ctx) => NotificationProvider(ctx)), ChangeNotifierProvider(create: (ctx) => WebSocketProvider(ctx)), + ChangeNotifierProvider(create: (ctx) => NotificationProvider(ctx)), ChangeNotifierProvider(create: (ctx) => ChatChannelProvider(ctx)), ], child: AppMainContent(), @@ -98,6 +98,7 @@ class AppMainContent extends StatelessWidget { context.read(); context.read(); context.read(); + context.read(); final th = context.watch(); diff --git a/lib/providers/notification.dart b/lib/providers/notification.dart index df37211..8475618 100644 --- a/lib/providers/notification.dart +++ b/lib/providers/notification.dart @@ -19,6 +19,13 @@ class NotificationProvider extends ChangeNotifier { _sn = context.read(); _ua = context.read(); _ws = context.read(); + + // Delay to wait user provider ready to use + Future.delayed(const Duration(milliseconds: 3000), () async { + if (!_ua.isAuthorized) return; + log("Registering push notifications..."); + await registerPushNotifications(); + }); } Future registerPushNotifications() async { diff --git a/lib/router.dart b/lib/router.dart index f5d0611..35d5c78 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -1,4 +1,5 @@ import 'package:animations/animations.dart'; +import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:surface/screens/account.dart'; import 'package:surface/screens/account/profile_edit.dart'; @@ -64,6 +65,7 @@ final _appRoutes = [ return FadeThroughTransition( animation: animation, secondaryAnimation: secondaryAnimation, + fillColor: Colors.transparent, child: AppBackground(isLessOptimization: true, child: child), ); }, @@ -82,6 +84,7 @@ final _appRoutes = [ return FadeThroughTransition( animation: animation, secondaryAnimation: secondaryAnimation, + fillColor: Colors.transparent, child: AppBackground(isLessOptimization: true, child: child), ); }, @@ -124,6 +127,7 @@ final _appRoutes = [ return FadeThroughTransition( animation: animation, secondaryAnimation: secondaryAnimation, + fillColor: Colors.transparent, child: AppBackground( isLessOptimization: true, child: child, @@ -153,6 +157,7 @@ final _appRoutes = [ return FadeThroughTransition( animation: animation, secondaryAnimation: secondaryAnimation, + fillColor: Colors.transparent, child: AppBackground( isLessOptimization: true, child: child, diff --git a/lib/screens/post/post_detail.dart b/lib/screens/post/post_detail.dart index 7a7f7c2..8f6d5e6 100644 --- a/lib/screens/post/post_detail.dart +++ b/lib/screens/post/post_detail.dart @@ -109,13 +109,11 @@ class _PostDetailScreenState extends State { ), if (_data != null) SliverToBoxAdapter( - child: Container( - constraints: const BoxConstraints(maxWidth: 640), - child: PostItem( - data: _data!, - showComments: false, - ), - ).center(), + child: PostItem( + data: _data!, + maxWidth: 640, + showComments: false, + ), ), const SliverToBoxAdapter(child: Divider(height: 1)), if (_data != null) diff --git a/lib/widgets/navigation/app_background.dart b/lib/widgets/navigation/app_background.dart index 2980ea1..1ffcbac 100644 --- a/lib/widgets/navigation/app_background.dart +++ b/lib/widgets/navigation/app_background.dart @@ -3,14 +3,17 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:responsive_framework/responsive_framework.dart'; class AppBackground extends StatelessWidget { final Widget child; final bool isLessOptimization; + final bool isRoot; const AppBackground({ super.key, required this.child, this.isLessOptimization = false, + this.isRoot = false, }); Widget _buildWithBackgroundImage( @@ -77,16 +80,24 @@ class AppBackground extends StatelessWidget { future: kIsWeb ? Future.value(null) : getApplicationDocumentsDirectory(), builder: (context, snapshot) { - if (snapshot.hasData) { - final path = '${snapshot.data!.path}/app_background_image'; - final file = File(path); - if (file.existsSync()) { - return _buildWithBackgroundImage(context, file, child); + if (isRoot || + ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) { + if (snapshot.hasData) { + final path = '${snapshot.data!.path}/app_background_image'; + final file = File(path); + if (file.existsSync()) { + return _buildWithBackgroundImage(context, file, child); + } } } + final backgroundColor = + ResponsiveBreakpoints.of(context).largerThan(MOBILE) + ? Colors.transparent + : Theme.of(context).colorScheme.surface; + return Material( - color: Theme.of(context).colorScheme.surface, + color: backgroundColor, child: child, ); }, diff --git a/lib/widgets/navigation/app_scaffold.dart b/lib/widgets/navigation/app_scaffold.dart index 267516b..dec9e84 100644 --- a/lib/widgets/navigation/app_scaffold.dart +++ b/lib/widgets/navigation/app_scaffold.dart @@ -88,6 +88,7 @@ class AppRootScaffold extends StatelessWidget { ); return AppBackground( + isRoot: true, child: Scaffold( body: Column( children: [