@@ -49,6 +49,8 @@ class AlertsSettingsState extends State<AlertsSettings> {
49
49
ThemeProvider ? _themeProvider;
50
50
late WebViewProvider _webViewProvider;
51
51
52
+ final _scrollController = ScrollController ();
53
+
52
54
@override
53
55
void initState () {
54
56
super .initState ();
@@ -63,6 +65,12 @@ class AlertsSettingsState extends State<AlertsSettings> {
63
65
routeName = "alerts" ;
64
66
}
65
67
68
+ @override
69
+ void dispose () {
70
+ _scrollController.dispose ();
71
+ super .dispose ();
72
+ }
73
+
66
74
@override
67
75
Widget build (BuildContext context) {
68
76
_themeProvider = Provider .of <ThemeProvider >(context, listen: false );
@@ -86,6 +94,7 @@ class AlertsSettingsState extends State<AlertsSettings> {
86
94
if (snapshot.data[0 ] is FirebaseUserModel ) {
87
95
_firebaseUserModel ?? = snapshot.data[0 ] as FirebaseUserModel ? ;
88
96
return SingleChildScrollView (
97
+ controller: _scrollController,
89
98
child: Column (
90
99
children: [
91
100
const Padding (
@@ -758,6 +767,13 @@ class AlertsSettingsState extends State<AlertsSettings> {
758
767
_firebaseUserModel? .retalsNotification = enabled;
759
768
});
760
769
firestore.toggleRetaliationNotification (enabled);
770
+
771
+ // Makes sure to scroll down so that the new 2 options are visible
772
+ _scrollController.animateTo (
773
+ _scrollController.offset + 100 ,
774
+ duration: const Duration (milliseconds: 200 ),
775
+ curve: Curves .easeIn,
776
+ );
761
777
} else {
762
778
String message = "" ;
763
779
int seconds = 0 ;
@@ -817,7 +833,6 @@ class AlertsSettingsState extends State<AlertsSettings> {
817
833
padding: const EdgeInsets .only (right: 10 ),
818
834
child: GestureDetector (
819
835
child: const Icon (Icons .info_outline_rounded),
820
- // Quick update
821
836
onTap: () async {
822
837
await showDialog (
823
838
useRootNavigator: false ,
@@ -843,6 +858,71 @@ class AlertsSettingsState extends State<AlertsSettings> {
843
858
],
844
859
),
845
860
),
861
+ if (_firebaseUserModel! .retalsNotification! && _factionApiAccess)
862
+ Padding (
863
+ padding: const EdgeInsets .fromLTRB (25 , 0 , 20 , 0 ),
864
+ child: Row (
865
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
866
+ children: < Widget > [
867
+ Flexible (
868
+ child: Row (
869
+ children: [
870
+ const Flexible (
871
+ child: Padding (
872
+ padding: EdgeInsets .only (left: 10 , right: 5 ),
873
+ child: Text (
874
+ "Only as API permission donor" ,
875
+ style: TextStyle (
876
+ fontSize: 15 ,
877
+ fontStyle: FontStyle .italic,
878
+ ),
879
+ ),
880
+ ),
881
+ ),
882
+ Padding (
883
+ padding: const EdgeInsets .only (right: 10 ),
884
+ child: GestureDetector (
885
+ child: const Icon (Icons .info_outline_rounded),
886
+ onTap: () async {
887
+ await showDialog (
888
+ useRootNavigator: false ,
889
+ context: context,
890
+ builder: (BuildContext context) {
891
+ return _retalsDonorExplanation ();
892
+ },
893
+ );
894
+ },
895
+ ),
896
+ ),
897
+ ],
898
+ ),
899
+ ),
900
+ Switch (
901
+ value: _firebaseUserModel? .retalsNotificationDonor ?? false ,
902
+ onChanged: (enabled) {
903
+ if (enabled) {
904
+ BotToast .showText (
905
+ text: "Please make sure that you understand the consequences of this setting "
906
+ "by reading the information dialog.\n\n "
907
+ "You will NOT receive relation alerts." ,
908
+ textStyle: const TextStyle (
909
+ fontSize: 14 ,
910
+ color: Colors .white,
911
+ ),
912
+ contentColor: Colors .blue,
913
+ duration: const Duration (seconds: 6 ),
914
+ contentPadding: const EdgeInsets .all (10 ),
915
+ );
916
+ }
917
+ setState (() {
918
+ _firebaseUserModel? .retalsNotificationDonor = enabled;
919
+ });
920
+ firestore.toggleRetaliationDonor (enabled);
921
+ },
922
+ ),
923
+ ],
924
+ ),
925
+ ),
846
926
const SizedBox (height: 60 ),
847
927
],
848
928
),
@@ -950,7 +1030,7 @@ class AlertsSettingsState extends State<AlertsSettings> {
950
1030
fontSize: 18 ,
951
1031
),
952
1032
),
953
- content: const SingleChildScrollView (
1033
+ content: SingleChildScrollView (
954
1034
child: Column (
955
1035
children: [
956
1036
Padding (
@@ -1190,6 +1270,46 @@ class AlertsSettingsState extends State<AlertsSettings> {
1190
1270
);
1191
1271
}
1192
1272
1273
+ AlertDialog _retalsDonorExplanation () {
1274
+ return AlertDialog (
1275
+ title: const Text ("Retaliation API Faction permissions donor" ),
1276
+ content: const Scrollbar (
1277
+ thumbVisibility: true ,
1278
+ child: SingleChildScrollView (
1279
+ child: Padding (
1280
+ padding: EdgeInsets .only (right: 12 ),
1281
+ child: Column (
1282
+ crossAxisAlignment: CrossAxisAlignment .start,
1283
+ children: [
1284
+ Text (
1285
+ "As explained in the Retalation Alerts information dialog, as a member of your faction with the "
1286
+ "required Faction API access, your API key send retaliation notifications to faction members. "
1287
+ "This will work as long as retalation alerts are active.\n\n "
1288
+ "However, if you personally would prefer NOT to receive these notifications but continue to act "
1289
+ "as a Faction API permission donor (so that the server can still notify other members), make "
1290
+ "sure to activate this option." ,
1291
+ style: TextStyle (fontSize: 13 ),
1292
+ ),
1293
+ SizedBox (height: 10 ),
1294
+ ],
1295
+ ),
1296
+ ),
1297
+ ),
1298
+ ),
1299
+ actions: [
1300
+ Padding (
1301
+ padding: const EdgeInsets .only (right: 8 ),
1302
+ child: TextButton (
1303
+ child: const Text ("Understood" ),
1304
+ onPressed: () {
1305
+ Navigator .of (context).pop ('exit' );
1306
+ },
1307
+ ),
1308
+ ),
1309
+ ],
1310
+ );
1311
+ }
1312
+
1193
1313
Future _getFactionApiAccess () async {
1194
1314
// Assess whether we have permits
1195
1315
final attacksResult = await Get .find <ApiCallerController >().getFactionAttacks ();
0 commit comments