mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-25 03:42:13 +00:00
add option to open system settings
This commit is contained in:
parent
61979aedcb
commit
7634177191
5 changed files with 50 additions and 1 deletions
|
|
@ -596,6 +596,18 @@ abstract class AppLocalizations {
|
||||||
/// **'Notification'**
|
/// **'Notification'**
|
||||||
String get settingsNotification;
|
String get settingsNotification;
|
||||||
|
|
||||||
|
/// No description provided for @settingsNotifyPermission.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Notification permissions'**
|
||||||
|
String get settingsNotifyPermission;
|
||||||
|
|
||||||
|
/// No description provided for @settingsNotifyPermissionDesc.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Open system settings to allow push notifications.'**
|
||||||
|
String get settingsNotifyPermissionDesc;
|
||||||
|
|
||||||
/// No description provided for @settingsNotifyTroubleshooting.
|
/// No description provided for @settingsNotifyTroubleshooting.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,13 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||||
@override
|
@override
|
||||||
String get settingsNotification => 'Benachrichtigung';
|
String get settingsNotification => 'Benachrichtigung';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get settingsNotifyPermission => 'Benachrichtigungsberechtigung';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get settingsNotifyPermissionDesc =>
|
||||||
|
'Systemeinstellungen öffnen, um Push-Benachrichtigungen zu erlauben.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get settingsNotifyTroubleshooting => 'Fehlersuche';
|
String get settingsNotifyTroubleshooting => 'Fehlersuche';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -273,6 +273,13 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||||
@override
|
@override
|
||||||
String get settingsNotification => 'Notification';
|
String get settingsNotification => 'Notification';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get settingsNotifyPermission => 'Notification permissions';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get settingsNotifyPermissionDesc =>
|
||||||
|
'Open system settings to allow push notifications.';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get settingsNotifyTroubleshooting => 'Troubleshooting';
|
String get settingsNotifyTroubleshooting => 'Troubleshooting';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9eeb6b5cb46410a1616c0dbd63ce74143dfdfbbc
|
Subproject commit 65bf6a4d161bfa0cd2db698446c58b4cd03db92c
|
||||||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:hashlib/random.dart';
|
import 'package:hashlib/random.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:twonly/locator.dart';
|
import 'package:twonly/locator.dart';
|
||||||
import 'package:twonly/src/model/protobuf/client/generated/push_notification.pb.dart';
|
import 'package:twonly/src/model/protobuf/client/generated/push_notification.pb.dart';
|
||||||
import 'package:twonly/src/services/notifications/fcm.notifications.dart';
|
import 'package:twonly/src/services/notifications/fcm.notifications.dart';
|
||||||
|
|
@ -22,6 +23,22 @@ class _NotificationViewState extends State<NotificationView> {
|
||||||
bool _isLoadingTroubleshooting = false;
|
bool _isLoadingTroubleshooting = false;
|
||||||
bool _isLoadingReset = false;
|
bool _isLoadingReset = false;
|
||||||
bool _troubleshootingDidRun = false;
|
bool _troubleshootingDidRun = false;
|
||||||
|
bool? _hasNotificationPermission;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_checkPermission();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _checkPermission() async {
|
||||||
|
final isGranted = await Permission.notification.isGranted;
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_hasNotificationPermission = isGranted;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _troubleshooting() async {
|
Future<void> _troubleshooting() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -93,6 +110,12 @@ class _NotificationViewState extends State<NotificationView> {
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
|
if (_hasNotificationPermission == false)
|
||||||
|
ListTile(
|
||||||
|
title: Text(context.lang.settingsNotifyPermission),
|
||||||
|
subtitle: Text(context.lang.settingsNotifyPermissionDesc),
|
||||||
|
onTap: openAppSettings,
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(context.lang.settingsNotifyTroubleshooting),
|
title: Text(context.lang.settingsNotifyTroubleshooting),
|
||||||
subtitle: Text(context.lang.settingsNotifyTroubleshootingDesc),
|
subtitle: Text(context.lang.settingsNotifyTroubleshootingDesc),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue