mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-04 12:24:47 +00:00
Different styling and management for dns upstream comments
This commit is contained in:
parent
d89d7ca2d6
commit
3a47490f46
4 changed files with 223 additions and 19 deletions
130
lib/screens/settings/dns/comment_modal.dart
Normal file
130
lib/screens/settings/dns/comment_modal.dart
Normal file
|
@ -0,0 +1,130 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class CommentModal extends StatefulWidget {
|
||||
final String? comment;
|
||||
final void Function(String) onConfirm;
|
||||
|
||||
const CommentModal({
|
||||
Key? key,
|
||||
this.comment,
|
||||
required this.onConfirm
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CommentModal> createState() => _CommentModalState();
|
||||
}
|
||||
|
||||
class _CommentModalState extends State<CommentModal> {
|
||||
final TextEditingController commentController = TextEditingController();
|
||||
|
||||
bool validData = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.comment != null) {
|
||||
commentController.text = widget.comment!.replaceFirst(RegExp(r'#(\s)?'), "");
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: MediaQuery.of(context).viewInsets,
|
||||
child: Container(
|
||||
height: 330,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(28),
|
||||
topRight: Radius.circular(28)
|
||||
),
|
||||
color: Theme.of(context).dialogBackgroundColor
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
physics: MediaQuery.of(context).size.height >= 330 == true
|
||||
? const NeverScrollableScrollPhysics()
|
||||
: null,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 28),
|
||||
child: Icon(
|
||||
Icons.comment_rounded,
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.comment,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||
child: TextFormField(
|
||||
controller: commentController,
|
||||
onChanged: (value) {
|
||||
if (value != '') {
|
||||
setState(() => validData = true);
|
||||
}
|
||||
else {
|
||||
setState(() => validData = false);
|
||||
}
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.comment_rounded),
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10)
|
||||
)
|
||||
),
|
||||
labelText: AppLocalizations.of(context)!.comment,
|
||||
helperText: AppLocalizations.of(context)!.commentsDescription,
|
||||
helperMaxLines: 3
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(AppLocalizations.of(context)!.cancel)
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
TextButton(
|
||||
onPressed: validData == true
|
||||
? () {
|
||||
Navigator.pop(context);
|
||||
widget.onConfirm("# ${commentController.text}");
|
||||
}
|
||||
: null,
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.confirm,
|
||||
style: TextStyle(
|
||||
color: validData == true
|
||||
? Theme.of(context).primaryColor
|
||||
: Colors.grey
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue