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