remove unnecessary safearea

This commit is contained in:
Fabian Freund
2024-06-16 21:15:50 +02:00
parent 33d6121053
commit 11e3b9c0a1
2 changed files with 334 additions and 342 deletions
@@ -25,44 +25,41 @@ class ChatArchiveListScreen extends HookConsumerWidget {
), ),
], ],
), ),
body: SafeArea( body: Skeletonizer(
child: Skeletonizer( enabled: chatsAsync.isLoading,
enabled: chatsAsync.isLoading, child: chatsAsync.when(
child: chatsAsync.when( data: (chats) {
data: (chats) { return ListView.builder(
return ListView.builder( itemCount: chats.length,
itemCount: chats.length, itemBuilder: (context, index) {
itemBuilder: (context, index) { final chat = chats[index];
final chat = chats[index];
return ListTile( return ListTile(
title: Text(chat.toString()), title: Text(chat.toString()),
subtitle: (chat.dateTime != null) subtitle: (chat.dateTime != null)
? Text(chat.dateTime!.formatWithMinutePrecision()) ? Text(chat.dateTime!.formatWithMinutePrecision())
: null, : null,
onTap: () async { onTap: () async {
await context.push( await context.push(
ChatArchiveDetailRoute(fileName: chat.fileName) ChatArchiveDetailRoute(fileName: chat.fileName).location,
.location, );
); },
}, );
); },
}, );
); },
}, error: (error, stackTrace) {
error: (error, stackTrace) { return FailureWidget(
return FailureWidget( title: 'Could not load archived chats',
title: 'Could not load archived chats', exception: error,
exception: error, onRetry: () => ref.refresh(chatArchiveRepositoryProvider),
onRetry: () => ref.refresh(chatArchiveRepositoryProvider), );
); },
}, loading: () => ListView.builder(
loading: () => ListView.builder( itemCount: 3,
itemCount: 3, itemBuilder: (context, index) => const ListTile(
itemBuilder: (context, index) => const ListTile( title: Bone.text(),
title: Bone.text(), subtitle: Bone.text(),
subtitle: Bone.text(),
),
), ),
), ),
), ),
@@ -90,332 +90,327 @@ class SettingsScreen extends HookConsumerWidget {
return Scaffold( return Scaffold(
appBar: AppBar(title: const Text('Settings')), appBar: AppBar(title: const Text('Settings')),
body: SafeArea( body: Padding(
child: Padding( padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.all(8.0), child: ListView(
child: ListView( children: [
children: [ _buildSection(theme, 'Kagi'),
_buildSection(theme, 'Kagi'), Padding(
Padding( padding: const EdgeInsets.only(
padding: const EdgeInsets.only( left: 16,
left: 16, right: 16,
right: 16, bottom: 8,
bottom: 8, ),
), child: TextField(
child: TextField( enableIMEPersonalizedLearning: false,
enableIMEPersonalizedLearning: false, autocorrect: false,
autocorrect: false, controller: kagiSessionTextController,
controller: kagiSessionTextController, obscureText: hideSessionText.value,
obscureText: hideSessionText.value, decoration: InputDecoration(
decoration: InputDecoration( label: const Text('Kagi Session Token'),
label: const Text('Kagi Session Token'), hintText: 'https://kagi.com/search?token=...',
hintText: 'https://kagi.com/search?token=...', helperMaxLines: 2,
helperMaxLines: 2, helper: Markdown(
helper: Markdown( shrinkWrap: true,
shrinkWrap: true, padding: EdgeInsets.zero,
padding: EdgeInsets.zero, data:
data: 'You can visit your [Kagi Account Settings](user_details) to get your Session Link.',
'You can visit your [Kagi Account Settings](user_details) to get your Session Link.', onTapLink: (text, href, title) async {
onTapLink: (text, href, title) async { if (href == 'user_details') {
if (href == 'user_details') { await ui_helper.launchUrlFeedback(
await ui_helper.launchUrlFeedback( context,
context, Uri.parse(
Uri.parse( 'https://kagi.com/settings?p=user_details',
'https://kagi.com/settings?p=user_details', ),
), );
); }
} },
}, ),
), suffixIcon: IconButton(
suffixIcon: IconButton( onPressed: () {
onPressed: () { hideSessionText.value = !hideSessionText.value;
hideSessionText.value = !hideSessionText.value; },
}, icon: Icon(
icon: Icon( hideSessionText.value
hideSessionText.value ? Icons.visibility
? Icons.visibility : Icons.visibility_off,
: Icons.visibility_off,
),
), ),
), ),
), ),
), ),
SwitchListTile.adaptive( ),
title: const Text('Show Early Access Features'), SwitchListTile.adaptive(
subtitle: const Text( title: const Text('Show Early Access Features'),
"Displays Kagi's early access features in the UI. As an Ultimate subscriber, you will likely want to have this enabled.", subtitle: const Text(
), "Displays Kagi's early access features in the UI. As an Ultimate subscriber, you will likely want to have this enabled.",
value: showEarlyAccessFeatures, ),
onChanged: (value) async { value: showEarlyAccessFeatures,
await ref.read(saveSettingsControllerProvider.notifier).save( onChanged: (value) async {
(currentSettings) => currentSettings.copyWith await ref.read(saveSettingsControllerProvider.notifier).save(
.showEarlyAccessFeatures(value), (currentSettings) => currentSettings.copyWith
); .showEarlyAccessFeatures(value),
);
},
),
const SizedBox(
height: 16,
),
_buildSection(theme, 'General'),
SwitchListTile.adaptive(
title: const Text('Incognito Mode'),
subtitle: const Text(
'Deletes all browsing data upon app restart for enhanced privacy.',
),
value: incognitoEnabled,
onChanged: (value) async {
await ref.read(saveSettingsControllerProvider.notifier).save(
(currentSettings) =>
currentSettings.copyWith.incognitoMode(value),
);
},
),
SwitchListTile.adaptive(
title: const Text('Enable JavaScript'),
subtitle: const Text(
'While turning off JavaScript boosts security, privacy, and speed, it may cause some sites to not work as intended.',
),
value: javacsriptEnabled,
onChanged: (value) async {
await ref.read(saveSettingsControllerProvider.notifier).save(
(currentSettings) =>
currentSettings.copyWith.enableJavascript(value),
);
},
),
SwitchListTile.adaptive(
title: const Text('Launch Links Externally'),
subtitle: const Text(
'Opens all links (except for kagi.com) in your default browser.',
),
value: launchUrlExternal,
onChanged: (value) async {
await ref.read(saveSettingsControllerProvider.notifier).save(
(currentSettings) =>
currentSettings.copyWith.launchUrlExternal(value),
);
},
),
const SizedBox(
height: 16,
),
_buildSection(theme, 'Bangs'),
ButtonListTile(
title: 'Bang Frequencies',
subtitle: 'Tracked usage for Bang recommendations',
button: FilledButton.icon(
onPressed: () async {
await ref
.read(bangDataRepositoryProvider.notifier)
.clearFrequency();
}, },
icon: const Icon(Icons.delete),
label: const Text('Clear'),
), ),
const SizedBox( ),
height: 16, Consumer(
), builder: (context, ref, child) {
_buildSection(theme, 'General'), final size = ref.watch(
SwitchListTile.adaptive( bangIconCacheSizeMegabytesProvider.select(
title: const Text('Incognito Mode'), (value) => value.valueOrNull,
subtitle: const Text( ),
'Deletes all browsing data upon app restart for enhanced privacy.', );
),
value: incognitoEnabled,
onChanged: (value) async {
await ref.read(saveSettingsControllerProvider.notifier).save(
(currentSettings) =>
currentSettings.copyWith.incognitoMode(value),
);
},
),
SwitchListTile.adaptive(
title: const Text('Enable JavaScript'),
subtitle: const Text(
'While turning off JavaScript boosts security, privacy, and speed, it may cause some sites to not work as intended.',
),
value: javacsriptEnabled,
onChanged: (value) async {
await ref.read(saveSettingsControllerProvider.notifier).save(
(currentSettings) =>
currentSettings.copyWith.enableJavascript(value),
);
},
),
SwitchListTile.adaptive(
title: const Text('Launch Links Externally'),
subtitle: const Text(
'Opens all links (except for kagi.com) in your default browser.',
),
value: launchUrlExternal,
onChanged: (value) async {
await ref.read(saveSettingsControllerProvider.notifier).save(
(currentSettings) =>
currentSettings.copyWith.launchUrlExternal(value),
);
},
),
const SizedBox(
height: 16,
),
_buildSection(theme, 'Bangs'),
ButtonListTile(
title: 'Bang Frequencies',
subtitle: 'Tracked usage for Bang recommendations',
button: FilledButton.icon(
onPressed: () async {
await ref
.read(bangDataRepositoryProvider.notifier)
.clearFrequency();
},
icon: const Icon(Icons.delete),
label: const Text('Clear'),
),
),
Consumer(
builder: (context, ref, child) {
final size = ref.watch(
bangIconCacheSizeMegabytesProvider.select(
(value) => value.valueOrNull,
),
);
return ButtonListTile( return ButtonListTile(
title: 'Icon Cache', title: 'Icon Cache',
subtitle: 'Stored favicons for Bangs', subtitle: 'Stored favicons for Bangs',
content: Padding( content: Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
child: DefaultTextStyle( child: DefaultTextStyle(
style: GoogleFonts.robotoMono(), style: GoogleFonts.robotoMono(),
child: Table( child: Table(
children: [ children: [
TableRow( TableRow(
children: [ children: [
const Text('Size'), const Text('Size'),
Text('${size?.toStringAsFixed(2) ?? 0} MB'), Text('${size?.toStringAsFixed(2) ?? 0} MB'),
], ],
), ),
], ],
),
), ),
), ),
button: FilledButton.icon( ),
onPressed: () async { button: FilledButton.icon(
await ref onPressed: () async {
.read(bangDataRepositoryProvider.notifier) await ref
.clearIconData(); .read(bangDataRepositoryProvider.notifier)
}, .clearIconData();
icon: const Icon(Icons.delete), },
label: const Text('Clear'), icon: const Icon(Icons.delete),
), label: const Text('Clear'),
); ),
}, );
), },
Consumer( ),
builder: (context, ref, child) { Consumer(
final lastSync = ref.watch( builder: (context, ref, child) {
lastSyncOfGroupProvider(BangGroup.general).select( final lastSync = ref.watch(
(value) => value.valueOrNull, lastSyncOfGroupProvider(BangGroup.general).select(
), (value) => value.valueOrNull,
); ),
);
final count = ref.watch( final count = ref.watch(
bangCountOfGroupProvider(BangGroup.general).select( bangCountOfGroupProvider(BangGroup.general).select(
(value) => value.valueOrNull, (value) => value.valueOrNull,
), ),
); );
return ButtonListTile( return ButtonListTile(
title: 'General Bangs', title: 'General Bangs',
subtitle: 'Automatically syncs every 7 days', subtitle: 'Automatically syncs every 7 days',
content: Padding( content: Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
child: DefaultTextStyle( child: DefaultTextStyle(
style: GoogleFonts.robotoMono(), style: GoogleFonts.robotoMono(),
child: Table( child: Table(
children: [ children: [
TableRow( TableRow(
children: [ children: [
const Text('Entries'), const Text('Entries'),
Text(count?.toString() ?? 'N/A'), Text(count?.toString() ?? 'N/A'),
], ],
), ),
TableRow( TableRow(
children: [ children: [
const Text('Last Sync'), const Text('Last Sync'),
Text( Text(
lastSync?.formatWithMinutePrecision() ?? lastSync?.formatWithMinutePrecision() ?? 'N/A',
'N/A', ),
), ],
], ),
), ],
],
),
), ),
), ),
button: FilledButton.icon( ),
onPressed: () async { button: FilledButton.icon(
await ref onPressed: () async {
.read(bangSyncRepositoryProvider.notifier) await ref
.syncGeneralBangs(); .read(bangSyncRepositoryProvider.notifier)
}, .syncGeneralBangs();
icon: const Icon(Icons.sync), },
label: const Text('Sync'), icon: const Icon(Icons.sync),
), label: const Text('Sync'),
); ),
}, );
), },
Consumer( ),
builder: (context, ref, child) { Consumer(
final lastSync = ref.watch( builder: (context, ref, child) {
lastSyncOfGroupProvider(BangGroup.assistant).select( final lastSync = ref.watch(
(value) => value.valueOrNull, lastSyncOfGroupProvider(BangGroup.assistant).select(
), (value) => value.valueOrNull,
); ),
);
final count = ref.watch( final count = ref.watch(
bangCountOfGroupProvider(BangGroup.assistant).select( bangCountOfGroupProvider(BangGroup.assistant).select(
(value) => value.valueOrNull, (value) => value.valueOrNull,
), ),
); );
return ButtonListTile( return ButtonListTile(
title: 'Assistant Bangs', title: 'Assistant Bangs',
subtitle: 'Automatically syncs every 7 days', subtitle: 'Automatically syncs every 7 days',
content: Padding( content: Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
child: DefaultTextStyle( child: DefaultTextStyle(
style: GoogleFonts.robotoMono(), style: GoogleFonts.robotoMono(),
child: Table( child: Table(
children: [ children: [
TableRow( TableRow(
children: [ children: [
const Text('Entries'), const Text('Entries'),
Text(count?.toString() ?? 'N/A'), Text(count?.toString() ?? 'N/A'),
], ],
), ),
TableRow( TableRow(
children: [ children: [
const Text('Last Sync'), const Text('Last Sync'),
Text( Text(
lastSync?.formatWithMinutePrecision() ?? lastSync?.formatWithMinutePrecision() ?? 'N/A',
'N/A', ),
), ],
], ),
), ],
],
),
), ),
), ),
button: FilledButton.icon( ),
onPressed: () async { button: FilledButton.icon(
await ref onPressed: () async {
.read(bangSyncRepositoryProvider.notifier) await ref
.syncAssistantBangs(); .read(bangSyncRepositoryProvider.notifier)
}, .syncAssistantBangs();
icon: const Icon(Icons.sync), },
label: const Text('Sync'), icon: const Icon(Icons.sync),
), label: const Text('Sync'),
); ),
}, );
), },
Consumer( ),
builder: (context, ref, child) { Consumer(
final lastSync = ref.watch( builder: (context, ref, child) {
lastSyncOfGroupProvider(BangGroup.kagi).select( final lastSync = ref.watch(
(value) => value.valueOrNull, lastSyncOfGroupProvider(BangGroup.kagi).select(
), (value) => value.valueOrNull,
); ),
);
final count = ref.watch( final count = ref.watch(
bangCountOfGroupProvider(BangGroup.kagi).select( bangCountOfGroupProvider(BangGroup.kagi).select(
(value) => value.valueOrNull, (value) => value.valueOrNull,
), ),
); );
return ButtonListTile( return ButtonListTile(
title: 'Kagi Bangs', title: 'Kagi Bangs',
subtitle: 'Automatically syncs every 7 days', subtitle: 'Automatically syncs every 7 days',
content: Padding( content: Padding(
padding: const EdgeInsets.only(top: 8.0), padding: const EdgeInsets.only(top: 8.0),
child: DefaultTextStyle( child: DefaultTextStyle(
style: GoogleFonts.robotoMono(), style: GoogleFonts.robotoMono(),
child: Table( child: Table(
children: [ children: [
TableRow( TableRow(
children: [ children: [
const Text('Entries'), const Text('Entries'),
Text(count?.toString() ?? 'N/A'), Text(count?.toString() ?? 'N/A'),
], ],
), ),
TableRow( TableRow(
children: [ children: [
const Text('Last Sync'), const Text('Last Sync'),
Text( Text(
lastSync?.formatWithMinutePrecision() ?? lastSync?.formatWithMinutePrecision() ?? 'N/A',
'N/A', ),
), ],
], ),
), ],
],
),
), ),
), ),
button: FilledButton.icon( ),
onPressed: () async { button: FilledButton.icon(
await ref onPressed: () async {
.read(bangSyncRepositoryProvider.notifier) await ref
.syncKagiBangs(); .read(bangSyncRepositoryProvider.notifier)
}, .syncKagiBangs();
icon: const Icon(Icons.sync), },
label: const Text('Sync'), icon: const Icon(Icons.sync),
), label: const Text('Sync'),
); ),
}, );
), },
], ),
), ],
), ),
), ),
); );