Skip to content

Commit

Permalink
Merge remote-tracking branch 'https://github.com/mrhcjones/Quacker/be…
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fbriere committed Dec 12, 2023
2 parents 8381ec6 + b2ac2b6 commit 0e1eeb4
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 187 deletions.
1 change: 1 addition & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage(
"Selecting individual accounts to import, and assigning groups are both planned for the future already!"),
"send": MessageLookupByLibrary.simpleMessage("Send"),
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
"share_base_url":
MessageLookupByLibrary.simpleMessage("Custom share URL"),
"share_base_url_description": MessageLookupByLibrary.simpleMessage(
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
"@joined": {},
"export": "Export",
"@export": {},
"settings": "Settings",
"@settings": {},
"data_exported_to_fullPath": "Data exported to {fullPath}",
"@data_exported_to_fullPath": {},
"data_exported_to_fileName": "Data exported to {fileName}",
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Future<void> main() async {
optionThemeMode: 'system',
optionThemeTrueBlack: false,
optionThemeMaterial3: false,
optionThemeColorScheme: 'gold',
optionThemeColorScheme: 'mango',
optionTweetsHideSensitive: false,
optionKeepFeedOffset: false,
optionLeanerFeeds: false,
Expand Down Expand Up @@ -264,7 +264,7 @@ class _SquawkerAppState extends State<SquawkerApp> with WidgetsBindingObserver {
String _themeMode = 'system';
bool _trueBlack = false;
bool _material3 = false;
FlexScheme _colorScheme = FlexScheme.gold;
FlexScheme _colorScheme = FlexScheme.mango;
Locale? _locale;
final _MyRouteObserver _routeObserver = _MyRouteObserver();

Expand Down
208 changes: 69 additions & 139 deletions lib/settings/_general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,6 @@ class SettingsGeneralFragment extends StatelessWidget {
]);
}

void _createTweetFontSizeDialog(BuildContext context) async {
int? selectedFontSize = await showDialog<int>(
context: context,
builder: (context) => FontSizePickerDialog(initialFontSize: _getOptionTweetFontSizeValue(context)),
);
if (selectedFontSize != null) {
PrefService.of(context).set<int>(optionTweetFontSize, selectedFontSize);
}
}

int _getOptionTweetFontSizeValue(BuildContext context) {
int optionTweetFontSizeValue =
PrefService.of(context).get<int>(optionTweetFontSize) ?? DefaultTextStyle.of(context).style.fontSize!.round();
return optionTweetFontSizeValue;
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -126,40 +110,6 @@ class SettingsGeneralFragment extends StatelessWidget {
items: defaultSubscriptionTabs
.map((e) => DropdownMenuItem(value: e.id, child: Text(e.titleBuilder(context))))
.toList()),
PrefDropdown(
fullWidth: false,
title: Text(L10n.of(context).media_size),
subtitle: Text(
L10n.of(context).save_bandwidth_using_smaller_images,
),
pref: optionMediaSize,
items: [
DropdownMenuItem(
value: 'disabled',
child: Text(L10n.of(context).disabled),
),
DropdownMenuItem(
value: 'thumb',
child: Text(L10n.of(context).thumbnail),
),
DropdownMenuItem(
value: 'small',
child: Text(L10n.of(context).small),
),
DropdownMenuItem(
value: 'medium',
child: Text(L10n.of(context).medium),
),
DropdownMenuItem(
value: 'large',
child: Text(L10n.of(context).large),
),
]),
PrefSwitch(
pref: optionMediaDefaultMute,
title: Text(L10n.of(context).mute_videos),
subtitle: Text(L10n.of(context).mute_video_description),
),
PrefSwitch(
pref: optionTweetsHideSensitive,
title: Text(L10n.of(context).hide_sensitive_tweets),
Expand All @@ -175,39 +125,79 @@ class SettingsGeneralFragment extends StatelessWidget {
subtitle: Text(L10n.of(context).disable_screenshots_hint),
pref: optionDisableScreenshots,
),
const DownloadTypeSetting(),
PrefSwitch(
title: Text(L10n.of(context).download_video_best_quality_label),
pref: optionDownloadBestVideoQuality,
subtitle: Text(L10n.of(context).download_video_best_quality_description),
),
PrefSwitch(
title: Text(L10n.of(context).activate_non_confirmation_bias_mode_label),
pref: optionNonConfirmationBiasMode,
subtitle: Text(L10n.of(context).activate_non_confirmation_bias_mode_description),
),
PrefSwitch(
title: Text(L10n.of(context).keep_feed_offset_label),
subtitle: Text(L10n.of(context).keep_feed_offset_description),
pref: optionKeepFeedOffset,
onChange: (value) async {
if (!value) {
var repository = await Repository.writable();
await repository.delete(tableFeedGroupPositionState);
}
},
),
PrefSwitch(
title: Text(L10n.of(context).leaner_feeds_label),
subtitle: Text(L10n.of(context).leaner_feeds_description),
pref: optionLeanerFeeds,
),
PrefButton(
title: Text(L10n.of(context).tweet_font_size_label),
subtitle: Text(L10n.of(context).tweet_font_size_description),
onTap: () => _createTweetFontSizeDialog(context),
child: Text('${_getOptionTweetFontSizeValue(context)} px'),
ExpansionTile(
title: Text(L10n.of(context).media),
leading: const Icon(Icons.image),
children: [
PrefDropdown(
fullWidth: false,
title: Text(L10n.of(context).media_size),
subtitle: Text(
L10n.of(context).save_bandwidth_using_smaller_images,
),
pref: optionMediaSize,
items: [
DropdownMenuItem(
value: 'disabled',
child: Text(L10n.of(context).disabled),
),
DropdownMenuItem(
value: 'thumb',
child: Text(L10n.of(context).thumbnail),
),
DropdownMenuItem(
value: 'small',
child: Text(L10n.of(context).small),
),
DropdownMenuItem(
value: 'medium',
child: Text(L10n.of(context).medium),
),
DropdownMenuItem(
value: 'large',
child: Text(L10n.of(context).large),
),
]),
PrefSwitch(
pref: optionMediaDefaultMute,
title: Text(L10n.of(context).mute_videos),
subtitle: Text(L10n.of(context).mute_video_description),
),
const DownloadTypeSetting(),
PrefSwitch(
title: Text(L10n.of(context).download_video_best_quality_label),
pref: optionDownloadBestVideoQuality,
subtitle: Text(L10n.of(context).download_video_best_quality_description),
),
],
),
ExpansionTile(
title: Text(L10n.of(context).feed),
leading: const Icon(Icons.rss_feed),
children: [
PrefSwitch(
title: Text(L10n.of(context).keep_feed_offset_label),
subtitle: Text(L10n.of(context).keep_feed_offset_description),
pref: optionKeepFeedOffset,
onChange: (value) async {
if (!value) {
var repository = await Repository.writable();
await repository.delete(tableFeedGroupPositionState);
}
},
),
PrefSwitch(
title: Text(L10n.of(context).leaner_feeds_label),
subtitle: Text(L10n.of(context).leaner_feeds_description),
pref: optionLeanerFeeds,
),
],
)
]),
),
);
Expand Down Expand Up @@ -248,8 +238,8 @@ class DownloadTypeSettingState extends State<DownloadTypeSetting> {
DeviceInfoPlugin plugin = DeviceInfoPlugin();
AndroidDeviceInfo android = await plugin.androidInfo;
var storagePermission = android.version.sdkInt < 30
? await Permission.storage.request()
: await Permission.manageExternalStorage.request();
? await Permission.storage.request()
: await Permission.manageExternalStorage.request();
if (storagePermission.isGranted) {
String? directoryPath = await FilePicker.platform.getDirectoryPath();
if (directoryPath == null) {
Expand Down Expand Up @@ -281,63 +271,3 @@ class DownloadTypeSettingState extends State<DownloadTypeSetting> {
);
}
}

class FontSizePickerDialog extends StatefulWidget {
/// initial selection for the slider
final int initialFontSize;

const FontSizePickerDialog({Key? key, required this.initialFontSize}) : super(key: key);

@override
FontSizePickerDialogState createState() => FontSizePickerDialogState();
}

class FontSizePickerDialogState extends State<FontSizePickerDialog> {
/// current selection of the slider
late int tweetFontSize;

@override
void initState() {
super.initState();
tweetFontSize = widget.initialFontSize;
}

@override
Widget build(BuildContext context) {
double defaultFontSize = DefaultTextStyle.of(context).style.fontSize!;
double minFontSize = defaultFontSize - 4;
double maxFontSize = defaultFontSize + 8;
return AlertDialog(
title: Text(L10n.of(context).tweet_font_size_label),
content: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text('$tweetFontSize px'),
Slider(
value: tweetFontSize.toDouble(),
min: minFontSize,
max: maxFontSize,
divisions: ((maxFontSize - minFontSize) / 2).round(),
label: '$tweetFontSize px',
onChanged: (value) {
setState(() {
tweetFontSize = value.round();
});
},
),
]
),

actions: [
TextButton(onPressed: () => Navigator.pop(context), child: Text(L10n.of(context).cancel)),
TextButton(
onPressed: () async {
Navigator.pop(context, tweetFontSize);
},
child: Text(L10n.of(context).save)
)
],
);
}
}
Loading

0 comments on commit 0e1eeb4

Please sign in to comment.