diff --git a/lib/main.dart b/lib/main.dart index d174f11..4b70bf9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,6 +2,7 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import 'package:solian/exts.dart'; import 'package:solian/firebase_options.dart'; import 'package:solian/providers/account.dart'; import 'package:solian/providers/auth.dart'; @@ -66,6 +67,13 @@ class SolianApp extends StatelessWidget { if (value) { Get.find().connect(); Get.find().connect(); + + try { + Get.find().registerPushNotifications(); + } catch (err) { + context.showSnackbar('pushNotifyRegisterFailed' + .trParams({'reason': err.toString()})); + } } }); }, diff --git a/lib/screens/account.dart b/lib/screens/account.dart index 4fe6467..847edb3 100644 --- a/lib/screens/account.dart +++ b/lib/screens/account.dart @@ -6,7 +6,6 @@ import 'package:solian/router.dart'; import 'package:solian/screens/auth/signin.dart'; import 'package:solian/screens/auth/signup.dart'; import 'package:solian/widgets/account/account_heading.dart'; -import 'package:solian/widgets/account/push_notify_register_dialog.dart'; class AccountScreen extends StatefulWidget { const AccountScreen({super.key}); @@ -102,31 +101,6 @@ class _AccountScreenState extends State { setState(() {}); }, ), - const Divider(thickness: 0.3, height: 0.3) - .paddingSymmetric(vertical: 16), - Wrap( - spacing: 4, - children: [ - InkWell( - child: Text( - 'pushNotifyRegisterAction'.tr, - style: TextStyle( - color: Theme.of(context) - .colorScheme - .onSurface - .withOpacity(0.85), - ), - ), - onTap: () { - showDialog( - context: context, - builder: (context) => - const PushNotifyRegisterDialog(), - ); - }, - ) - ], - ) ], ); }, diff --git a/lib/translations.dart b/lib/translations.dart index 16f017f..09e5eea 100644 --- a/lib/translations.dart +++ b/lib/translations.dart @@ -193,11 +193,13 @@ class SolianMessages extends Translations { 'badgeSolsynthStaff': 'Solsynth Staff', 'badgeSolarOriginalCitizen': 'Solar Network Natives', 'badgeGreatCommunityContributor': 'Great Community Contributor', - 'pushNotifyRegisterAction': 'Enable Push Notifications', 'pushNotifyRegister': 'Register Push Notification Device', 'pushNotifyRegisterCaption': - 'Activating push notifications allows you to get our latest notifications even when the app is completely closed. We use Apple\'s official push service on iOS/macOS devices; other devices provide push notifications through Google Firebase. To register a device for push notifications, you may need to connect to Google\'s servers and install the Google Framework on your device.', - 'pushNotifyRegisterDone': 'Push Notifications has been activated.', + 'Activating push notifications allows you to get our latest notifications even when the app is completely closed. We use Apple\'s official push service on iOS/macOS devices; other devices provide push notifications through Google Firebase. To register a device for push notifications, you may need to connect to Google\'s servers and install the Google Framework on your device. Although you dismiss this dialog, this registration will be auto performed when you next time launch the app.', + 'pushNotifyRegisterDone': 'Push notifications has been activated.', + 'pushNotifyRegisterFailed': + 'Unable to active push notification... @reason', + 'about': 'About', }, 'zh_CN': { 'hide': '隐藏', @@ -377,11 +379,12 @@ class SolianMessages extends Translations { 'badgeSolsynthStaff': 'Solsynth 工作人员', 'badgeSolarOriginalCitizen': 'Solar Network 原住民', 'badgeGreatCommunityContributor': '优秀社区贡献者', - 'pushNotifyRegisterAction': '激活推送通知', 'pushNotifyRegister': '注册推送通知设备', 'pushNotifyRegisterCaption': - '激活推送通知便可以让你在应用程序完全关闭的时候仍然获取到我们最新的通知。在 iOS/macOS 设备上我们使用 Apple 官方的推送服务;其他设备则通过 Google Firebase 提供推送通知。要注册推送通知设备,您可能需要连接到 Google 的服务器(在中国大陆不可用)并在您的设备上安装 Google Framework。', + '激活推送通知便可以让你在应用程序完全关闭的时候仍然获取到我们最新的通知。在 iOS/macOS 设备上我们使用 Apple 官方的推送服务;其他设备则通过 Google Firebase 提供推送通知。要注册推送通知设备,您可能需要连接到 Google 的服务器(在中国大陆不可用)并在您的设备上安装 Google Framework。即使您关闭此对话框,下次启动应用程序时仍会自动执行此注册。', 'pushNotifyRegisterDone': '推送通知已成功激活', + 'pushNotifyRegisterFailed': '推送通知激活失败…… @reason', + 'about': '关于', } }; } diff --git a/lib/widgets/chat/chat_message_input.dart b/lib/widgets/chat/chat_message_input.dart index 0f1718a..7a99f3a 100644 --- a/lib/widgets/chat/chat_message_input.dart +++ b/lib/widgets/chat/chat_message_input.dart @@ -166,7 +166,7 @@ class _ChatMessageInputState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Divider(thickness: 0.3, height: 0.3), + const Divider(thickness: 0.3, height: 1), if (_replyTo != null) MaterialBanner( leading: const FaIcon(FontAwesomeIcons.reply, size: 18),