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,150 +266,154 @@ 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(
decoration: BoxDecoration( borderRadius: BorderRadius.circular(20.0),
gradient: LinearGradient( child: SingleChildScrollView(
begin: Alignment.topRight, child: Container(
end: Alignment.bottomLeft, decoration: BoxDecoration(
colors: [ gradient: LinearGradient(
Color(0xffe242bc), begin: Alignment.topRight,
Color(0xfff4727c), end: Alignment.bottomLeft,
], colors: [
), Color(0xffe242bc),
borderRadius: BorderRadius.circular(20.0), Color(0xfff4727c),
), ],
padding: EdgeInsets.all(25.0), ),
child: Column( ),
mainAxisSize: MainAxisSize.min, padding: EdgeInsets.all(25.0),
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
Row( crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Icon( Row(
Icons.warning_amber_sharp, children: [
color: Colors.white, Icon(
), Icons.warning_amber_sharp,
SizedBox(width: 10), color: Colors.white,
Text( ),
translate("Warning"), SizedBox(width: 10),
style: TextStyle( Text(
color: Colors.white, translate("Warning"),
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
],
),
SizedBox(height: 20),
Center(
child: Image.asset('assets/scam.png',
width: 180,
),
),
SizedBox(height: 18),
Text(
translate("scam_title"),
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 22.0,
),
),
SizedBox(height: 18),
SizedBox(
height: screenHeight * 0.3,
child: Scrollbar(
child: SingleChildScrollView(
child: Text(
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: 20.0,
), ),
),
],
),
SizedBox(height: 20),
Center(
child: Image.asset(
'assets/scam.png',
width: 180,
), ),
), ),
), SizedBox(height: 18),
),
Row(
children: <Widget>[
Checkbox(
value: show_warning,
onChanged: (value) {
setState((){
show_warning = value!;
});
},
),
Text( Text(
translate("Don't show again"), translate("scam_title"),
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 15.0, fontSize: 22.0,
), ),
), ),
SizedBox(height: 18),
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(
value: show_warning,
onChanged: (value) {
setState(() {
show_warning = value!;
});
},
),
Text(
translate("Don't show again"),
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
constraints: BoxConstraints(maxWidth: 150),
child: ElevatedButton(
onPressed: isButtonLocked
? null
: () {
Navigator.of(context).pop();
_serverModel.toggleService();
if (show_warning) {
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"),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13.0,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
),
SizedBox(width: 15),
Container(
constraints: BoxConstraints(maxWidth: 150),
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
style: ElevatedButton.styleFrom(
primary: Colors.blueAccent,
),
child: Text(
translate("Decline"),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13.0,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
),
],
),
], ],
), ),
SizedBox(height: 10), ),
Row( ),
mainAxisAlignment: MainAxisAlignment.end, ),
children: [ contentPadding: EdgeInsets.all(0.0),
Container(
constraints: BoxConstraints(maxWidth: 150),
child: ElevatedButton(
onPressed: isButtonLocked
? null
: () {
Navigator.of(context).pop();
_serverModel.toggleService();
if (show_warning) {
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"),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13.0,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
),
SizedBox(width: 15),
Container(
constraints: BoxConstraints(maxWidth: 150),
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
style: ElevatedButton.styleFrom(
primary: Colors.blueAccent,
),
child: Text(
translate("Decline"),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 13.0,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
),
],
)])),
contentPadding: EdgeInsets.all(0.0),
); );
} }
} }
@ -550,10 +553,14 @@ 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"),
? () => showScamWarning(context, serverModel) serverModel.mediaOk,
: serverModel.toggleService), !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, PermissionRow(translate("Input Control"), serverModel.inputOk,
serverModel.toggleInput), serverModel.toggleInput),
PermissionRow(translate("Transfer file"), serverModel.fileOk, PermissionRow(translate("Transfer file"), serverModel.fileOk,
@ -795,7 +802,7 @@ void androidChannelInit() {
} }
return ""; return "";
}); });
} }
void showScamWarning(BuildContext context, ServerModel serverModel) { void showScamWarning(BuildContext context, ServerModel serverModel) {
showDialog( showDialog(