Removed color appbar desktop mode

This commit is contained in:
Juan Gilsanz Polo 2023-10-29 02:47:14 +01:00
parent 96fe7eb730
commit 91d4d2c87a
26 changed files with 1607 additions and 1527 deletions

View file

@ -11,6 +11,7 @@ import 'package:adguard_home_manager/screens/settings/dns_rewrites/delete_dns_re
import 'package:adguard_home_manager/screens/settings/dns_rewrites/dns_rewrite_modal.dart';
import 'package:adguard_home_manager/providers/app_config_provider.dart';
import 'package:adguard_home_manager/functions/desktop_mode.dart';
import 'package:adguard_home_manager/functions/snackbar.dart';
import 'package:adguard_home_manager/constants/enums.dart';
import 'package:adguard_home_manager/providers/rewrite_rules_provider.dart';
@ -129,193 +130,195 @@ class _DnsRewritesScreenState extends State<DnsRewritesScreen> {
}
}
Widget generateBody() {
switch (rewriteRulesProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingRewriteRules,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case LoadStatus.loaded:
if (rewriteRulesProvider.rewriteRules!.isNotEmpty) {
return RefreshIndicator(
onRefresh: () async {
final result = await rewriteRulesProvider.fetchRules();
if (result == false) {
showSnacbkar(
appConfigProvider: appConfigProvider,
label: AppLocalizations.of(context)!.rewriteRulesNotLoaded,
color: Colors.red
);
}
},
child: ListView.builder(
controller: scrollController,
padding: const EdgeInsets.only(top: 0),
itemCount: rewriteRulesProvider.rewriteRules!.length,
itemBuilder: (context, index) => Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: InkWell(
onTap: () => {
if (width > 900 || !(Platform.isAndroid || Platform.isIOS)) {
showDialog(
context: context,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: true,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
)
}
else {
showModalBottomSheet(
context: context,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: false,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
backgroundColor: Colors.transparent,
isScrollControlled: true,
)
}
},
borderRadius: BorderRadius.circular(10),
child: Padding(
padding: const EdgeInsets.only(
left: 16, top: 16, bottom: 16, right: 8
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
"${AppLocalizations.of(context)!.domain}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].domain,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
const SizedBox(height: 3),
Row(
children: [
Text(
"${AppLocalizations.of(context)!.answer}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].answer,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
],
),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Theme.of(context).colorScheme.onSurfaceVariant,
)
],
),
),
),
)
),
);
}
else {
return Center(
child: Text(
AppLocalizations.of(context)!.noRewriteRules,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);
}
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.rewriteRulesNotLoaded,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
}
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.dnsRewrites),
surfaceTintColor: isDesktop(width) ? Colors.transparent : null,
centerTitle: false,
),
body: Stack(
children: [
generateBody(),
Builder(
builder: (context) {
switch (rewriteRulesProvider.loadStatus) {
case LoadStatus.loading:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const CircularProgressIndicator(),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.loadingRewriteRules,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
case LoadStatus.loaded:
if (rewriteRulesProvider.rewriteRules!.isNotEmpty) {
return RefreshIndicator(
onRefresh: () async {
final result = await rewriteRulesProvider.fetchRules();
if (result == false) {
showSnacbkar(
appConfigProvider: appConfigProvider,
label: AppLocalizations.of(context)!.rewriteRulesNotLoaded,
color: Colors.red
);
}
},
child: ListView.builder(
controller: scrollController,
padding: const EdgeInsets.only(top: 0),
itemCount: rewriteRulesProvider.rewriteRules!.length,
itemBuilder: (context, index) => Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: InkWell(
onTap: () => {
if (width > 900 || !(Platform.isAndroid || Platform.isIOS)) {
showDialog(
context: context,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: true,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
)
}
else {
showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) => DnsRewriteModal(
onConfirm: updateRewriteRule,
dialog: false,
rule: rewriteRulesProvider.rewriteRules![index],
onDelete: (rule) => showDialog(
context: context,
builder: (context) => DeleteDnsRewrite(
onConfirm: () => deleteDnsRewrite(rule)
)
),
),
backgroundColor: Colors.transparent,
isScrollControlled: true,
)
}
},
borderRadius: BorderRadius.circular(10),
child: Padding(
padding: const EdgeInsets.only(
left: 16, top: 16, bottom: 16, right: 8
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
"${AppLocalizations.of(context)!.domain}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].domain,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
const SizedBox(height: 3),
Row(
children: [
Text(
"${AppLocalizations.of(context)!.answer}: ",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Theme.of(context).colorScheme.onSurface
),
),
Text(
rewriteRulesProvider.rewriteRules![index].answer,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface
),
),
],
),
],
),
Icon(
Icons.keyboard_arrow_right_rounded,
color: Theme.of(context).colorScheme.onSurfaceVariant,
)
],
),
),
),
)
),
);
}
else {
return Center(
child: Text(
AppLocalizations.of(context)!.noRewriteRules,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);
}
case LoadStatus.error:
return SizedBox(
width: double.maxFinite,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
color: Colors.red,
size: 50,
),
const SizedBox(height: 30),
Text(
AppLocalizations.of(context)!.rewriteRulesNotLoaded,
style: TextStyle(
fontSize: 22,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
)
],
),
);
default:
return const SizedBox();
}
},
),
AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
@ -344,6 +347,7 @@ class _DnsRewritesScreenState extends State<DnsRewritesScreen> {
else {
showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) => DnsRewriteModal(
onConfirm: addDnsRewrite,
dialog: false,