Large header settings

This commit is contained in:
Juan Gilsanz Polo
2024-06-11 18:45:02 +02:00
parent 84d08ae9a0
commit bfaa8bf356
7 changed files with 334 additions and 235 deletions

View File

@@ -16,137 +16,162 @@ import 'package:linkdy/i18n/strings.g.dart';
import 'package:linkdy/providers/app_status.provider.dart';
class Customization extends ConsumerWidget {
const Customization({Key? key}) : super(key: key);
const Customization({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
appBar: AppBar(
title: Text(t.settings.customization.customization),
centerTitle: false,
),
body: SafeArea(
child: ListView(
children: [
SectionLabel(
label: t.settings.customization.theme,
padding: const EdgeInsets.only(top: 10, left: 16, right: 16, bottom: 5),
body: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar.large(
pinned: true,
floating: true,
centerTitle: false,
forceElevated: innerBoxIsScrolled,
title: Text(t.settings.customization.customization),
),
Column(
children: [
CustomSwitchListTile(
value: ref.watch(appStatusProvider).selectedTheme == SelectedTheme.system ? true : false,
onChanged: (value) => ref
.read(appStatusProvider.notifier)
.setTheme(value == true ? SelectedTheme.system : SelectedTheme.light),
title: t.settings.customization.systemDefined,
),
],
body: SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (context) => CustomScrollView(
slivers: [
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
SliverList.list(
children: [
ThemeModeButton(
icon: Icons.light_mode,
value: 1,
selected: ref.watch(appStatusProvider).selectedTheme.index,
label: t.settings.customization.light,
onChanged: (value) => ref.read(appStatusProvider.notifier).setTheme(SelectedTheme.values[value]),
disabled: ref.watch(appStatusProvider).selectedTheme == SelectedTheme.system ? true : false,
SectionLabel(
label: t.settings.customization.theme,
padding: const EdgeInsets.only(top: 10, left: 16, right: 16, bottom: 5),
),
ThemeModeButton(
icon: Icons.dark_mode,
value: 2,
selected: ref.watch(appStatusProvider).selectedTheme.index,
label: t.settings.customization.dark,
onChanged: (value) => ref.read(appStatusProvider.notifier).setTheme(SelectedTheme.values[value]),
disabled: ref.watch(appStatusProvider).selectedTheme == SelectedTheme.system ? true : false,
Column(
children: [
CustomSwitchListTile(
value: ref.watch(appStatusProvider).selectedTheme == SelectedTheme.system ? true : false,
onChanged: (value) => ref
.read(appStatusProvider.notifier)
.setTheme(value == true ? SelectedTheme.system : SelectedTheme.light),
title: t.settings.customization.systemDefined,
),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ThemeModeButton(
icon: Icons.light_mode,
value: 1,
selected: ref.watch(appStatusProvider).selectedTheme.index,
label: t.settings.customization.light,
onChanged: (value) =>
ref.read(appStatusProvider.notifier).setTheme(SelectedTheme.values[value]),
disabled:
ref.watch(appStatusProvider).selectedTheme == SelectedTheme.system ? true : false,
),
ThemeModeButton(
icon: Icons.dark_mode,
value: 2,
selected: ref.watch(appStatusProvider).selectedTheme.index,
label: t.settings.customization.dark,
onChanged: (value) =>
ref.read(appStatusProvider.notifier).setTheme(SelectedTheme.values[value]),
disabled:
ref.watch(appStatusProvider).selectedTheme == SelectedTheme.system ? true : false,
),
],
),
],
),
SectionLabel(
label: t.settings.customization.color,
padding: const EdgeInsets.only(top: 45, left: 16, right: 16, bottom: 5),
),
if (ref.watch(appStatusProvider).supportsDynamicTheme)
CustomSwitchListTile(
value: ref.watch(appStatusProvider).useDynamicTheme,
onChanged: ref.read(appStatusProvider.notifier).setUseDynamicTheme,
title: t.settings.customization.useDynamicTheme,
),
if (ref.watch(appStatusProvider).supportsDynamicTheme == false ||
(ref.watch(appStatusProvider).supportsDynamicTheme == true &&
ref.watch(appStatusProvider).useDynamicTheme == false))
Padding(
padding: const EdgeInsets.only(bottom: 8, left: 16, right: 16),
child: Scrollbar(
controller: ref.watch(customizationProvider).scrollController,
thumbVisibility: Platform.isMacOS || Platform.isLinux || Platform.isWindows,
interactive: Platform.isMacOS || Platform.isLinux || Platform.isWindows,
thickness: Platform.isMacOS || Platform.isLinux || Platform.isWindows ? 8 : 0,
child: Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: MediaQuery.of(context).size.width,
height: 70,
child: ListView.builder(
controller: ref.watch(customizationProvider).scrollController,
scrollDirection: Axis.horizontal,
itemCount: colors.length,
padding: const EdgeInsets.all(0),
itemBuilder: (context, index) {
if (index == 0) {
return Row(
children: [
ColorItem(
index: index,
total: colors.length,
color: colors[index],
numericValue: index,
selectedValue: ref.watch(appStatusProvider).selectedColor,
onChanged: ref.read(appStatusProvider.notifier).setSelectedColor,
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
width: 1,
height: 60,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(1),
),
),
],
);
} else {
return ColorItem(
index: index,
total: colors.length,
color: colors[index],
numericValue: index,
selectedValue: ref.watch(appStatusProvider).selectedColor,
onChanged: ref.read(appStatusProvider.notifier).setSelectedColor,
);
}
},
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
colorTranslation(ref.watch(appStatusProvider).selectedColor),
style: TextStyle(color: Theme.of(context).listTileTheme.iconColor, fontSize: 16),
),
),
],
),
),
),
),
],
),
],
),
SectionLabel(
label: t.settings.customization.color,
padding: const EdgeInsets.only(top: 45, left: 16, right: 16, bottom: 5),
),
if (ref.watch(appStatusProvider).supportsDynamicTheme)
CustomSwitchListTile(
value: ref.watch(appStatusProvider).useDynamicTheme,
onChanged: ref.read(appStatusProvider.notifier).setUseDynamicTheme,
title: t.settings.customization.useDynamicTheme,
),
if (ref.watch(appStatusProvider).supportsDynamicTheme == false ||
(ref.watch(appStatusProvider).supportsDynamicTheme == true &&
ref.watch(appStatusProvider).useDynamicTheme == false))
Padding(
padding: const EdgeInsets.only(bottom: 8, left: 16, right: 16),
child: Scrollbar(
controller: ref.watch(customizationProvider).scrollController,
thumbVisibility: Platform.isMacOS || Platform.isLinux || Platform.isWindows,
interactive: Platform.isMacOS || Platform.isLinux || Platform.isWindows,
thickness: Platform.isMacOS || Platform.isLinux || Platform.isWindows ? 8 : 0,
child: Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: MediaQuery.of(context).size.width,
height: 70,
child: ListView.builder(
controller: ref.watch(customizationProvider).scrollController,
scrollDirection: Axis.horizontal,
itemCount: colors.length,
padding: const EdgeInsets.all(0),
itemBuilder: (context, index) {
if (index == 0) {
return Row(
children: [
ColorItem(
index: index,
total: colors.length,
color: colors[index],
numericValue: index,
selectedValue: ref.watch(appStatusProvider).selectedColor,
onChanged: ref.read(appStatusProvider.notifier).setSelectedColor,
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 10),
width: 1,
height: 60,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(1),
),
),
],
);
} else {
return ColorItem(
index: index,
total: colors.length,
color: colors[index],
numericValue: index,
selectedValue: ref.watch(appStatusProvider).selectedColor,
onChanged: ref.read(appStatusProvider.notifier).setSelectedColor,
);
}
},
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
colorTranslation(ref.watch(appStatusProvider).selectedColor),
style: TextStyle(color: Theme.of(context).listTileTheme.iconColor, fontSize: 16),
),
),
],
),
),
),
),
],
),
),
),
);

View File

@@ -1,14 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:linkdy/constants/enums.dart';
import 'package:linkdy/i18n/strings.g.dart';
import 'package:linkdy/screens/settings/ui/general_settings/browser_mode_selection_modal.dart';
import 'package:linkdy/screens/settings/ui/general_settings/disconnect_modal.dart';
import 'package:linkdy/providers/app_status.provider.dart';
import 'package:linkdy/widgets/section_label.dart';
import 'package:linkdy/i18n/strings.g.dart';
import 'package:linkdy/providers/app_status.provider.dart';
import 'package:linkdy/constants/enums.dart';
class GeneralSettings extends ConsumerWidget {
const GeneralSettings({super.key});
@@ -33,47 +33,76 @@ class GeneralSettings extends ConsumerWidget {
}
return Scaffold(
appBar: AppBar(
title: Text(t.settings.generalSettings.generalSettings),
),
body: ListView(
children: [
SectionLabel(label: t.settings.generalSettings.bookmarks),
SwitchListTile(
title: Text(t.settings.generalSettings.showFavicon),
subtitle: Text(t.settings.generalSettings.showFaviconDescription),
value: ref.watch(appStatusProvider).showFavicon,
onChanged: ref.read(appStatusProvider.notifier).setShowFavicon,
),
ListTile(
title: Text(t.settings.generalSettings.openLinksWith),
subtitle: Text(browserLabel()),
onTap: openBrowserSelectionSheet,
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Divider(),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton.icon(
onPressed: () => showDialog(
context: context,
builder: (context) => const DisconnectModal(),
),
icon: const Icon(Icons.clear_rounded),
label: Text(
t.settings.generalSettings.disconnectFromServer,
),
style: const ButtonStyle(
foregroundColor: MaterialStatePropertyAll(Colors.white),
backgroundColor: MaterialStatePropertyAll(Colors.red),
),
),
],
body: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar.large(
pinned: true,
floating: true,
centerTitle: false,
forceElevated: innerBoxIsScrolled,
title: Text(t.settings.generalSettings.generalSettings),
),
),
],
body: SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (context) => CustomScrollView(
slivers: [
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
SliverList.list(
children: [
SectionLabel(label: t.settings.generalSettings.bookmarks),
SwitchListTile(
title: Text(t.settings.generalSettings.showFavicon),
subtitle: Text(t.settings.generalSettings.showFaviconDescription),
value: ref.watch(appStatusProvider).showFavicon,
onChanged: ref.read(appStatusProvider.notifier).setShowFavicon,
),
ListTile(
title: Text(t.settings.generalSettings.openLinksWith),
subtitle: Text(browserLabel()),
onTap: openBrowserSelectionSheet,
),
SectionLabel(label: t.settings.generalSettings.tags),
ListTile(
title: Text(t.settings.generalSettings.defaultTags),
subtitle: Text(t.settings.generalSettings.defaultTagsDescription),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Divider(),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FilledButton.icon(
onPressed: () => showDialog(
context: context,
builder: (context) => const DisconnectModal(),
),
icon: const Icon(Icons.clear_rounded),
label: Text(
t.settings.generalSettings.disconnectFromServer,
),
style: const ButtonStyle(
foregroundColor: MaterialStatePropertyAll(Colors.white),
backgroundColor: MaterialStatePropertyAll(Colors.red),
),
),
],
),
],
),
],
),
),
),
),
);
}

View File

@@ -12,7 +12,6 @@ import 'package:linkdy/widgets/section_label.dart';
import 'package:linkdy/widgets/custom_list_tile.dart';
import 'package:linkdy/widgets/custom_settings_tile.dart';
import 'package:linkdy/providers/router.provider.dart';
import 'package:linkdy/providers/app_info.provider.dart';
import 'package:linkdy/utils/open_url.dart';
import 'package:linkdy/constants/strings.dart';
@@ -51,77 +50,100 @@ class _List extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
appBar: AppBar(
leading: BackButton(onPressed: () => ref.read(routerProvider).pop()),
title: Text(t.settings.settings),
),
body: ListView(
children: [
SectionLabel(label: t.settings.appSettings),
_SettingsTile(
icon: Icons.palette_rounded,
title: t.settings.customization.customization,
subtitle: t.settings.customization.customizationDescription,
thisItem: 0,
twoColumns: tabletView,
screenToNavigate: const Customization(),
),
_SettingsTile(
icon: Icons.settings_rounded,
title: t.settings.generalSettings.generalSettings,
subtitle: t.settings.generalSettings.generalSettingsDescription,
thisItem: 1,
screenToNavigate: const GeneralSettings(),
twoColumns: tabletView,
),
SectionLabel(label: t.settings.aboutApp),
CustomListTile(
title: t.settings.linkdingRepository,
subtitle: t.settings.linkdingRepositoryDescription,
trailing: Icon(
Icons.open_in_new_rounded,
color: Theme.of(context).colorScheme.onSurfaceVariant,
body: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar.large(
pinned: true,
floating: true,
centerTitle: false,
forceElevated: innerBoxIsScrolled,
title: Text(t.settings.settings),
),
onTap: () => openUrlCustomTab(Urls.linkdingRepo),
),
CustomListTile(
title: t.settings.appVersion,
subtitle: ref.watch(appInfoProvider).version,
),
CustomListTile(
title: t.settings.createdBy,
subtitle: Strings.createdBy,
),
Padding(
padding: const EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (Platform.isAndroid)
IconButton(
onPressed: () => openUrlCustomTab(Urls.playStoreLink),
icon: SvgPicture.asset(
'assets/resources/google-play.svg',
color: Theme.of(context).colorScheme.onSurfaceVariant,
width: 30,
height: 30,
],
body: SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (context) => CustomScrollView(
slivers: [
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
SliverList.list(
children: [
SectionLabel(label: t.settings.appSettings),
_SettingsTile(
icon: Icons.palette_rounded,
title: t.settings.customization.customization,
subtitle: t.settings.customization.customizationDescription,
thisItem: 0,
twoColumns: tabletView,
screenToNavigate: const Customization(),
),
tooltip: t.settings.visitGooglePlay,
),
IconButton(
onPressed: () => openUrlCustomTab(Urls.gitHubRepo),
icon: SvgPicture.asset(
'assets/resources/github.svg',
color: Theme.of(context).colorScheme.onSurfaceVariant,
width: 30,
height: 30,
),
tooltip: t.settings.visitGitHubRepo,
_SettingsTile(
icon: Icons.settings_rounded,
title: t.settings.generalSettings.generalSettings,
subtitle: t.settings.generalSettings.generalSettingsDescription,
thisItem: 1,
screenToNavigate: const GeneralSettings(),
twoColumns: tabletView,
),
SectionLabel(label: t.settings.aboutApp),
CustomListTile(
title: t.settings.linkdingRepository,
subtitle: t.settings.linkdingRepositoryDescription,
trailing: Icon(
Icons.open_in_new_rounded,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
onTap: () => openUrlCustomTab(Urls.linkdingRepo),
),
CustomListTile(
title: t.settings.appVersion,
subtitle: ref.watch(appInfoProvider).version,
),
CustomListTile(
title: t.settings.createdBy,
subtitle: Strings.createdBy,
),
Padding(
padding: const EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (Platform.isAndroid)
IconButton(
onPressed: () => openUrlCustomTab(Urls.playStoreLink),
icon: SvgPicture.asset(
'assets/resources/google-play.svg',
color: Theme.of(context).colorScheme.onSurfaceVariant,
width: 30,
height: 30,
),
tooltip: t.settings.visitGooglePlay,
),
IconButton(
onPressed: () => openUrlCustomTab(Urls.gitHubRepo),
icon: SvgPicture.asset(
'assets/resources/github.svg',
color: Theme.of(context).colorScheme.onSurfaceVariant,
width: 30,
height: 30,
),
tooltip: t.settings.visitGitHubRepo,
),
],
),
),
],
),
],
),
),
],
),
),
);
}
@@ -131,7 +153,6 @@ class _SettingsTile extends ConsumerWidget {
final String title;
final String subtitle;
final IconData icon;
final Widget? trailing;
final Widget screenToNavigate;
final int thisItem;
final bool twoColumns;
@@ -140,7 +161,6 @@ class _SettingsTile extends ConsumerWidget {
required this.title,
required this.subtitle,
required this.icon,
this.trailing,
required this.screenToNavigate,
required this.thisItem,
required this.twoColumns,
@@ -153,7 +173,6 @@ class _SettingsTile extends ConsumerWidget {
title: title,
subtitle: subtitle,
icon: icon,
trailing: trailing,
thisItem: thisItem,
selectedItem: ref.watch(settingsProvider).selectedScreen,
onTap: () {
@@ -166,7 +185,6 @@ class _SettingsTile extends ConsumerWidget {
title: title,
subtitle: subtitle,
icon: icon,
trailing: trailing,
onTap: () {
Navigator.of(context, rootNavigator: true).push(MaterialPageRoute(builder: (context) => screenToNavigate));
},