scrollable scam warning dialog (#6850)

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
This commit is contained in:
Sahil Yeole 2024-01-11 09:35:30 +05:30 committed by GitHub
parent ebfbc8ce61
commit ce0fc14a8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,7 +221,6 @@ class ServiceNotRunningNotification extends StatelessWidget {
], ],
)); ));
} }
} }
class ScamWarningDialog extends StatefulWidget { class ScamWarningDialog extends StatefulWidget {
@ -267,10 +266,12 @@ class _ScamWarningDialogState extends State<ScamWarningDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isButtonLocked = _countdown > 0; final isButtonLocked = _countdown > 0;
final screenHeight = MediaQuery.of(context).size.height;
return AlertDialog( return AlertDialog(
content: Container( content: ClipRRect(
borderRadius: BorderRadius.circular(20.0),
child: SingleChildScrollView(
child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topRight, begin: Alignment.topRight,
@ -280,7 +281,6 @@ class _ScamWarningDialogState extends State<ScamWarningDialog> {
Color(0xfff4727c), Color(0xfff4727c),
], ],
), ),
borderRadius: BorderRadius.circular(20.0),
), ),
padding: EdgeInsets.all(25.0), padding: EdgeInsets.all(25.0),
child: Column( child: Column(
@ -306,7 +306,8 @@ class _ScamWarningDialogState extends State<ScamWarningDialog> {
), ),
SizedBox(height: 20), SizedBox(height: 20),
Center( Center(
child: Image.asset('assets/scam.png', child: Image.asset(
'assets/scam.png',
width: 180, width: 180,
), ),
), ),
@ -321,28 +322,23 @@ class _ScamWarningDialogState extends State<ScamWarningDialog> {
), ),
), ),
SizedBox(height: 18), SizedBox(height: 18),
SizedBox( Text(
height: screenHeight * 0.3, translate("scam_text1") +
child: Scrollbar( "\n\n" +
child: SingleChildScrollView( translate("scam_text2") +
child: Text( "\n",
translate("scam_text1")+"\n\n"
+translate("scam_text2")+"\n",
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16.0, fontSize: 16.0,
), ),
), ),
),
),
),
Row( Row(
children: <Widget>[ children: <Widget>[
Checkbox( Checkbox(
value: show_warning, value: show_warning,
onChanged: (value) { onChanged: (value) {
setState((){ setState(() {
show_warning = value!; show_warning = value!;
}); });
}, },
@ -357,7 +353,6 @@ class _ScamWarningDialogState extends State<ScamWarningDialog> {
), ),
], ],
), ),
SizedBox(height: 10),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@ -370,14 +365,17 @@ class _ScamWarningDialogState extends State<ScamWarningDialog> {
Navigator.of(context).pop(); Navigator.of(context).pop();
_serverModel.toggleService(); _serverModel.toggleService();
if (show_warning) { if (show_warning) {
bind.mainSetLocalOption(key: "show-scam-warning", value: "N"); bind.mainSetLocalOption(
key: "show-scam-warning", value: "N");
} }
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.blueAccent, primary: Colors.blueAccent,
), ),
child: Text( child: Text(
isButtonLocked ? translate("I Agree")+" (${_countdown}s)" : translate("I Agree"), isButtonLocked
? translate("I Agree") + " (${_countdown}s)"
: translate("I Agree"),
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 13.0, fontSize: 13.0,
@ -409,7 +407,12 @@ class _ScamWarningDialogState extends State<ScamWarningDialog> {
), ),
), ),
], ],
)])), ),
],
),
),
),
),
contentPadding: EdgeInsets.all(0.0), contentPadding: EdgeInsets.all(0.0),
); );
} }
@ -550,8 +553,12 @@ class _PermissionCheckerState extends State<PermissionChecker> {
label: Text(translate("Stop service"))) label: Text(translate("Stop service")))
.marginOnly(bottom: 8) .marginOnly(bottom: 8)
: SizedBox.shrink(), : SizedBox.shrink(),
PermissionRow(translate("Screen Capture"), serverModel.mediaOk, PermissionRow(
!serverModel.mediaOk && gFFI.userModel.userName.value.isEmpty && bind.mainGetLocalOption(key: "show-scam-warning") != "N" translate("Screen Capture"),
serverModel.mediaOk,
!serverModel.mediaOk &&
gFFI.userModel.userName.value.isEmpty &&
bind.mainGetLocalOption(key: "show-scam-warning") != "N"
? () => showScamWarning(context, serverModel) ? () => showScamWarning(context, serverModel)
: serverModel.toggleService), : serverModel.toggleService),
PermissionRow(translate("Input Control"), serverModel.inputOk, PermissionRow(translate("Input Control"), serverModel.inputOk,