✨ Push token push (to server)
This commit is contained in:
parent
d41e358c6a
commit
7e63611416
@ -74,8 +74,8 @@ class SolianApp extends StatelessWidget {
|
|||||||
Provider(create: (ctx) => SnAttachmentProvider(ctx)),
|
Provider(create: (ctx) => SnAttachmentProvider(ctx)),
|
||||||
Provider(create: (ctx) => UserDirectoryProvider(ctx)),
|
Provider(create: (ctx) => UserDirectoryProvider(ctx)),
|
||||||
ChangeNotifierProvider(create: (ctx) => UserProvider(ctx)),
|
ChangeNotifierProvider(create: (ctx) => UserProvider(ctx)),
|
||||||
ChangeNotifierProvider(create: (ctx) => NotificationProvider(ctx)),
|
|
||||||
ChangeNotifierProvider(create: (ctx) => WebSocketProvider(ctx)),
|
ChangeNotifierProvider(create: (ctx) => WebSocketProvider(ctx)),
|
||||||
|
ChangeNotifierProvider(create: (ctx) => NotificationProvider(ctx)),
|
||||||
ChangeNotifierProvider(create: (ctx) => ChatChannelProvider(ctx)),
|
ChangeNotifierProvider(create: (ctx) => ChatChannelProvider(ctx)),
|
||||||
],
|
],
|
||||||
child: AppMainContent(),
|
child: AppMainContent(),
|
||||||
@ -98,6 +98,7 @@ class AppMainContent extends StatelessWidget {
|
|||||||
context.read<NavigationProvider>();
|
context.read<NavigationProvider>();
|
||||||
context.read<WebSocketProvider>();
|
context.read<WebSocketProvider>();
|
||||||
context.read<ChatChannelProvider>();
|
context.read<ChatChannelProvider>();
|
||||||
|
context.read<NotificationProvider>();
|
||||||
|
|
||||||
final th = context.watch<ThemeProvider>();
|
final th = context.watch<ThemeProvider>();
|
||||||
|
|
||||||
|
@ -19,6 +19,13 @@ class NotificationProvider extends ChangeNotifier {
|
|||||||
_sn = context.read<SnNetworkProvider>();
|
_sn = context.read<SnNetworkProvider>();
|
||||||
_ua = context.read<UserProvider>();
|
_ua = context.read<UserProvider>();
|
||||||
_ws = context.read<WebSocketProvider>();
|
_ws = context.read<WebSocketProvider>();
|
||||||
|
|
||||||
|
// 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<void> registerPushNotifications() async {
|
Future<void> registerPushNotifications() async {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:surface/screens/account.dart';
|
import 'package:surface/screens/account.dart';
|
||||||
import 'package:surface/screens/account/profile_edit.dart';
|
import 'package:surface/screens/account/profile_edit.dart';
|
||||||
@ -64,6 +65,7 @@ final _appRoutes = [
|
|||||||
return FadeThroughTransition(
|
return FadeThroughTransition(
|
||||||
animation: animation,
|
animation: animation,
|
||||||
secondaryAnimation: secondaryAnimation,
|
secondaryAnimation: secondaryAnimation,
|
||||||
|
fillColor: Colors.transparent,
|
||||||
child: AppBackground(isLessOptimization: true, child: child),
|
child: AppBackground(isLessOptimization: true, child: child),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -82,6 +84,7 @@ final _appRoutes = [
|
|||||||
return FadeThroughTransition(
|
return FadeThroughTransition(
|
||||||
animation: animation,
|
animation: animation,
|
||||||
secondaryAnimation: secondaryAnimation,
|
secondaryAnimation: secondaryAnimation,
|
||||||
|
fillColor: Colors.transparent,
|
||||||
child: AppBackground(isLessOptimization: true, child: child),
|
child: AppBackground(isLessOptimization: true, child: child),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -124,6 +127,7 @@ final _appRoutes = [
|
|||||||
return FadeThroughTransition(
|
return FadeThroughTransition(
|
||||||
animation: animation,
|
animation: animation,
|
||||||
secondaryAnimation: secondaryAnimation,
|
secondaryAnimation: secondaryAnimation,
|
||||||
|
fillColor: Colors.transparent,
|
||||||
child: AppBackground(
|
child: AppBackground(
|
||||||
isLessOptimization: true,
|
isLessOptimization: true,
|
||||||
child: child,
|
child: child,
|
||||||
@ -153,6 +157,7 @@ final _appRoutes = [
|
|||||||
return FadeThroughTransition(
|
return FadeThroughTransition(
|
||||||
animation: animation,
|
animation: animation,
|
||||||
secondaryAnimation: secondaryAnimation,
|
secondaryAnimation: secondaryAnimation,
|
||||||
|
fillColor: Colors.transparent,
|
||||||
child: AppBackground(
|
child: AppBackground(
|
||||||
isLessOptimization: true,
|
isLessOptimization: true,
|
||||||
child: child,
|
child: child,
|
||||||
|
@ -109,13 +109,11 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
),
|
),
|
||||||
if (_data != null)
|
if (_data != null)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Container(
|
child: PostItem(
|
||||||
constraints: const BoxConstraints(maxWidth: 640),
|
data: _data!,
|
||||||
child: PostItem(
|
maxWidth: 640,
|
||||||
data: _data!,
|
showComments: false,
|
||||||
showComments: false,
|
),
|
||||||
),
|
|
||||||
).center(),
|
|
||||||
),
|
),
|
||||||
const SliverToBoxAdapter(child: Divider(height: 1)),
|
const SliverToBoxAdapter(child: Divider(height: 1)),
|
||||||
if (_data != null)
|
if (_data != null)
|
||||||
|
@ -3,14 +3,17 @@ import 'dart:io';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:responsive_framework/responsive_framework.dart';
|
||||||
|
|
||||||
class AppBackground extends StatelessWidget {
|
class AppBackground extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final bool isLessOptimization;
|
final bool isLessOptimization;
|
||||||
|
final bool isRoot;
|
||||||
const AppBackground({
|
const AppBackground({
|
||||||
super.key,
|
super.key,
|
||||||
required this.child,
|
required this.child,
|
||||||
this.isLessOptimization = false,
|
this.isLessOptimization = false,
|
||||||
|
this.isRoot = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
Widget _buildWithBackgroundImage(
|
Widget _buildWithBackgroundImage(
|
||||||
@ -77,16 +80,24 @@ class AppBackground extends StatelessWidget {
|
|||||||
future:
|
future:
|
||||||
kIsWeb ? Future.value(null) : getApplicationDocumentsDirectory(),
|
kIsWeb ? Future.value(null) : getApplicationDocumentsDirectory(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (isRoot ||
|
||||||
final path = '${snapshot.data!.path}/app_background_image';
|
ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) {
|
||||||
final file = File(path);
|
if (snapshot.hasData) {
|
||||||
if (file.existsSync()) {
|
final path = '${snapshot.data!.path}/app_background_image';
|
||||||
return _buildWithBackgroundImage(context, file, child);
|
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(
|
return Material(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: backgroundColor,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -88,6 +88,7 @@ class AppRootScaffold extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return AppBackground(
|
return AppBackground(
|
||||||
|
isRoot: true,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
|
Loading…
Reference in New Issue
Block a user