Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 72 additions & 81 deletions lib/settings/pages/debug_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,71 +57,65 @@ class _DebugSettingsPageState extends State<DebugSettingsPage> {
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: SettingsListTile(
icon: Icons.co_present_rounded,
description: l10n.deleteLocalPreferences,
widget: const SizedBox(
height: 42.0,
child: Icon(Icons.chevron_right_rounded),
),
onTap: () async {
showThunderDialog<void>(
context: context,
title: l10n.deleteLocalPreferences,
contentText: l10n.deleteLocalPreferencesDescription,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
secondaryButtonText: l10n.cancel,
onPrimaryButtonPressed: (dialogContext, _) {
SharedPreferences.getInstance().then((prefs) async {
await prefs.clear();
child: SettingsListTile(
icon: Icons.co_present_rounded,
description: l10n.deleteLocalPreferences,
widget: const SizedBox(
height: 42.0,
child: Icon(Icons.chevron_right_rounded),
),
onTap: () async {
showThunderDialog<void>(
context: context,
title: l10n.deleteLocalPreferences,
contentText: l10n.deleteLocalPreferencesDescription,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
secondaryButtonText: l10n.cancel,
onPrimaryButtonPressed: (dialogContext, _) {
SharedPreferences.getInstance().then((prefs) async {
await prefs.clear();

if (context.mounted) {
context.read<ThunderBloc>().add(UserPreferencesChangeEvent());
showSnackbar(AppLocalizations.of(context)!.clearedUserPreferences);
}
});
if (context.mounted) {
context.read<ThunderBloc>().add(UserPreferencesChangeEvent());
showSnackbar(AppLocalizations.of(context)!.clearedUserPreferences);
}
});

Navigator.of(dialogContext).pop();
},
primaryButtonText: l10n.clearPreferences,
);
},
),
Navigator.of(dialogContext).pop();
},
primaryButtonText: l10n.clearPreferences,
);
},
),
),
const SliverToBoxAdapter(child: SizedBox(height: 8.0)),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: SettingsListTile(
icon: Icons.data_array_rounded,
description: l10n.deleteLocalDatabase,
widget: const SizedBox(
height: 42.0,
child: Icon(Icons.chevron_right_rounded),
),
onTap: () async {
showThunderDialog<void>(
context: context,
title: l10n.deleteLocalDatabase,
contentText: l10n.deleteLocalDatabaseDescription,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
secondaryButtonText: l10n.cancel,
onPrimaryButtonPressed: (dialogContext, _) async {
String path = join(await getDatabasesPath(), 'thunder.db');
await databaseFactory.deleteDatabase(path);

if (context.mounted) {
showSnackbar(AppLocalizations.of(context)!.clearedDatabase);
Navigator.of(context).pop();
}
},
primaryButtonText: l10n.clearDatabase,
);
},
child: SettingsListTile(
icon: Icons.data_array_rounded,
description: l10n.deleteLocalDatabase,
widget: const SizedBox(
height: 42.0,
child: Icon(Icons.chevron_right_rounded),
),
onTap: () async {
showThunderDialog<void>(
context: context,
title: l10n.deleteLocalDatabase,
contentText: l10n.deleteLocalDatabaseDescription,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
secondaryButtonText: l10n.cancel,
onPrimaryButtonPressed: (dialogContext, _) async {
String path = join(await getDatabasesPath(), 'thunder.db');
await databaseFactory.deleteDatabase(path);

if (context.mounted) {
showSnackbar(AppLocalizations.of(context)!.clearedDatabase);
Navigator.of(context).pop();
}
},
primaryButtonText: l10n.clearDatabase,
);
},
),
),
SliverToBoxAdapter(
Expand All @@ -134,29 +128,26 @@ class _DebugSettingsPageState extends State<DebugSettingsPage> {
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: FutureBuilder<int>(
future: getExtendedImageCacheSize(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return SettingsListTile(
icon: Icons.data_saver_off_rounded,
description: l10n.clearCache('${(snapshot.data! / (1024 * 1024)).toStringAsFixed(2)} MB'),
widget: const SizedBox(
height: 42.0,
child: Icon(Icons.chevron_right_rounded),
),
onTap: () async {
await clearDiskCachedImages();
if (context.mounted) showSnackbar(l10n.clearedCache);
setState(() {}); // Trigger a rebuild to refresh the cache size
},
);
}
return Container();
},
),
child: FutureBuilder<int>(
future: getExtendedImageCacheSize(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return SettingsListTile(
icon: Icons.data_saver_off_rounded,
description: l10n.clearCache('${(snapshot.data! / (1024 * 1024)).toStringAsFixed(2)} MB'),
widget: const SizedBox(
height: 42.0,
child: Icon(Icons.chevron_right_rounded),
),
onTap: () async {
await clearDiskCachedImages();
if (context.mounted) showSnackbar(l10n.clearedCache);
setState(() {}); // Trigger a rebuild to refresh the cache size
},
);
}
return Container();
},
),
),
],
Expand Down
66 changes: 33 additions & 33 deletions lib/settings/pages/filter_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,44 +138,44 @@ class _FilterSettingsPageState extends State<FilterSettingsPage> with SingleTick
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
child: Align(
alignment: Alignment.centerLeft,
child: keywordFilters.isEmpty
? Text(
child: Align(
alignment: Alignment.centerLeft,
child: keywordFilters.isEmpty
? Padding(
padding: const EdgeInsets.only(left: 16.0, right: 16.0),
child: Text(
l10n.noKeywordFilters,
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.textTheme.bodyMedium?.color?.withOpacity(0.8),
),
)
: ListView.builder(
padding: const EdgeInsets.only(bottom: 20),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: keywordFilters.length,
itemBuilder: (context, index) {
return SettingsListTile(
description: keywordFilters[index],
widget: const SizedBox(height: 42.0, child: Icon(Icons.chevron_right_rounded)),
onTap: () async {
showThunderDialog(
context: context,
title: l10n.removeKeywordFilter,
contentText: l10n.removeKeyword(keywordFilters[index]),
primaryButtonText: l10n.remove,
onPrimaryButtonPressed: (dialogContext, setPrimaryButtonEnabled) {
setPreferences(LocalSettings.keywordFilters, keywordFilters.where((element) => element != keywordFilters[index]).toList());
Navigator.of(dialogContext).pop();
},
secondaryButtonText: l10n.cancel,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
);
},
);
},
),
),
)
: ListView.builder(
padding: const EdgeInsets.only(bottom: 20),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: keywordFilters.length,
itemBuilder: (context, index) {
return SettingsListTile(
description: keywordFilters[index],
widget: const SizedBox(height: 42.0, child: Icon(Icons.chevron_right_rounded)),
onTap: () async {
showThunderDialog(
context: context,
title: l10n.removeKeywordFilter,
contentText: l10n.removeKeyword(keywordFilters[index]),
primaryButtonText: l10n.remove,
onPrimaryButtonPressed: (dialogContext, setPrimaryButtonEnabled) {
setPreferences(LocalSettings.keywordFilters, keywordFilters.where((element) => element != keywordFilters[index]).toList());
Navigator.of(dialogContext).pop();
},
secondaryButtonText: l10n.cancel,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
);
},
);
},
),
),
),
const SliverToBoxAdapter(child: SizedBox(height: 128.0)),
Expand Down
29 changes: 19 additions & 10 deletions lib/shared/advanced_share_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,18 @@ void showAdvancedShareSheet(BuildContext context, PostViewMedia postViewMedia) a
}

return Padding(
padding: const EdgeInsets.only(left: 30, right: 30, bottom: 30),
padding: const EdgeInsets.only(left: 14, right: 14, bottom: 30),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.centerLeft,
child: Text(
AppLocalizations.of(context)!.preview,
style: theme.textTheme.titleLarge,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
AppLocalizations.of(context)!.preview,
style: theme.textTheme.titleLarge,
),
),
),
if (!_canShare(options, postViewMedia))
Expand Down Expand Up @@ -213,9 +216,12 @@ void showAdvancedShareSheet(BuildContext context, PostViewMedia postViewMedia) a
const SizedBox(height: 20),
Align(
alignment: Alignment.centerLeft,
child: Text(
AppLocalizations.of(context)!.image,
style: theme.textTheme.titleLarge,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
AppLocalizations.of(context)!.image,
style: theme.textTheme.titleLarge,
),
),
),
ToggleOption(
Expand Down Expand Up @@ -263,9 +269,12 @@ void showAdvancedShareSheet(BuildContext context, PostViewMedia postViewMedia) a
const SizedBox(height: 20),
Align(
alignment: Alignment.centerLeft,
child: Text(
AppLocalizations.of(context)!.link(0),
style: theme.textTheme.titleLarge,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
AppLocalizations.of(context)!.link(0),
style: theme.textTheme.titleLarge,
),
),
),
ToggleOption(
Expand Down
Loading