first commit
This commit is contained in:
+112
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import '../../services/finamp_settings_helper.dart';
|
||||
|
||||
enum ContentGridViewCrossAxisCountType {
|
||||
portrait,
|
||||
landscape;
|
||||
|
||||
/// Human-readable version of the [ContentGridViewCrossAxisCountType]. For
|
||||
/// example, toString() on [ContentGridViewCrossAxisCountType.portrait],
|
||||
/// toString() would return "ContentGridViewCrossAxisCountType.portrait". With
|
||||
/// this function, the same input would return "Portrait".
|
||||
@override
|
||||
@Deprecated("Use toLocalisedString when possible")
|
||||
String toString() => _humanReadableName(this);
|
||||
|
||||
String toLocalisedString(BuildContext context) =>
|
||||
_humanReadableLocalisedName(this, context);
|
||||
|
||||
String _humanReadableName(
|
||||
ContentGridViewCrossAxisCountType contentGridViewCrossAxisCountType) {
|
||||
switch (contentGridViewCrossAxisCountType) {
|
||||
case ContentGridViewCrossAxisCountType.portrait:
|
||||
return "Portrait";
|
||||
case ContentGridViewCrossAxisCountType.landscape:
|
||||
return "Landscape";
|
||||
}
|
||||
}
|
||||
|
||||
String _humanReadableLocalisedName(
|
||||
ContentGridViewCrossAxisCountType contentGridViewCrossAxisCountType,
|
||||
BuildContext context) {
|
||||
switch (contentGridViewCrossAxisCountType) {
|
||||
case ContentGridViewCrossAxisCountType.portrait:
|
||||
return AppLocalizations.of(context)!.portrait;
|
||||
case ContentGridViewCrossAxisCountType.landscape:
|
||||
return AppLocalizations.of(context)!.landscape;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ContentGridViewCrossAxisCountListTile extends StatefulWidget {
|
||||
const ContentGridViewCrossAxisCountListTile({
|
||||
Key? key,
|
||||
required this.type,
|
||||
}) : super(key: key);
|
||||
|
||||
final ContentGridViewCrossAxisCountType type;
|
||||
|
||||
@override
|
||||
State<ContentGridViewCrossAxisCountListTile> createState() =>
|
||||
_ContentGridViewCrossAxisCountListTileState();
|
||||
}
|
||||
|
||||
class _ContentGridViewCrossAxisCountListTileState
|
||||
extends State<ContentGridViewCrossAxisCountListTile> {
|
||||
final _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
switch (widget.type) {
|
||||
case ContentGridViewCrossAxisCountType.portrait:
|
||||
_controller.text = FinampSettingsHelper
|
||||
.finampSettings.contentGridViewCrossAxisCountPortrait
|
||||
.toString();
|
||||
break;
|
||||
case ContentGridViewCrossAxisCountType.landscape:
|
||||
_controller.text = FinampSettingsHelper
|
||||
.finampSettings.contentGridViewCrossAxisCountLandscape
|
||||
.toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text(AppLocalizations.of(context)!
|
||||
.gridCrossAxisCount(widget.type.toLocalisedString(context))),
|
||||
subtitle: Text(
|
||||
AppLocalizations.of(context)!.gridCrossAxisCountSubtitle(
|
||||
widget.type.toLocalisedString(context).toLowerCase()),
|
||||
),
|
||||
trailing: SizedBox(
|
||||
width: 50 * MediaQuery.of(context).textScaleFactor,
|
||||
child: TextField(
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
keyboardType: TextInputType.number,
|
||||
onChanged: (value) {
|
||||
final valueInt = int.tryParse(value);
|
||||
|
||||
if (valueInt != null && valueInt > 0) {
|
||||
switch (widget.type) {
|
||||
case ContentGridViewCrossAxisCountType.portrait:
|
||||
FinampSettingsHelper.setContentGridViewCrossAxisCountPortrait(
|
||||
valueInt);
|
||||
break;
|
||||
case ContentGridViewCrossAxisCountType.landscape:
|
||||
FinampSettingsHelper
|
||||
.setContentGridViewCrossAxisCountLandscape(valueInt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../../models/finamp_models.dart';
|
||||
import '../../services/finamp_settings_helper.dart';
|
||||
|
||||
class ContentViewTypeDropdownListTile extends StatelessWidget {
|
||||
const ContentViewTypeDropdownListTile({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<Box<FinampSettings>>(
|
||||
valueListenable: FinampSettingsHelper.finampSettingsListener,
|
||||
builder: (_, box, __) {
|
||||
return ListTile(
|
||||
title: Text(AppLocalizations.of(context)!.viewType),
|
||||
subtitle: Text(AppLocalizations.of(context)!.viewTypeSubtitle),
|
||||
trailing: DropdownButton<ContentViewType>(
|
||||
value: box.get("FinampSettings")?.contentViewType,
|
||||
items: ContentViewType.values
|
||||
.map((e) => DropdownMenuItem<ContentViewType>(
|
||||
value: e,
|
||||
child: Text(e.toLocalisedString(context)),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
FinampSettingsHelper.setContentViewType(value);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../../models/finamp_models.dart';
|
||||
import '../../services/finamp_settings_helper.dart';
|
||||
|
||||
class HideSongArtistsIfSameAsAlbumArtistsSelector extends StatelessWidget {
|
||||
const HideSongArtistsIfSameAsAlbumArtistsSelector({Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<Box<FinampSettings>>(
|
||||
valueListenable: FinampSettingsHelper.finampSettingsListener,
|
||||
builder: (_, box, __) {
|
||||
return SwitchListTile.adaptive(
|
||||
title: Text(AppLocalizations.of(context)!
|
||||
.hideSongArtistsIfSameAsAlbumArtists),
|
||||
subtitle: Text(AppLocalizations.of(context)!
|
||||
.hideSongArtistsIfSameAsAlbumArtistsSubtitle),
|
||||
value: FinampSettingsHelper
|
||||
.finampSettings.hideSongArtistsIfSameAsAlbumArtists,
|
||||
onChanged: (value) =>
|
||||
FinampSettingsHelper.setHideSongArtistsIfSameAsAlbumArtists(
|
||||
value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../../models/finamp_models.dart';
|
||||
import '../../services/finamp_settings_helper.dart';
|
||||
|
||||
class ShowCoverAsPlayerBackgroundSelector extends StatelessWidget {
|
||||
const ShowCoverAsPlayerBackgroundSelector({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<Box<FinampSettings>>(
|
||||
valueListenable: FinampSettingsHelper.finampSettingsListener,
|
||||
builder: (_, box, __) {
|
||||
return SwitchListTile.adaptive(
|
||||
title:
|
||||
Text(AppLocalizations.of(context)!.showCoverAsPlayerBackground),
|
||||
subtitle: Text(AppLocalizations.of(context)!
|
||||
.showCoverAsPlayerBackgroundSubtitle),
|
||||
value:
|
||||
FinampSettingsHelper.finampSettings.showCoverAsPlayerBackground,
|
||||
onChanged: (value) =>
|
||||
FinampSettingsHelper.setShowCoverAsPlayerBackground(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../../models/finamp_models.dart';
|
||||
import '../../services/finamp_settings_helper.dart';
|
||||
|
||||
class ShowTextOnGridViewSelector extends StatelessWidget {
|
||||
const ShowTextOnGridViewSelector({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<Box<FinampSettings>>(
|
||||
valueListenable: FinampSettingsHelper.finampSettingsListener,
|
||||
builder: (_, box, __) {
|
||||
return SwitchListTile.adaptive(
|
||||
title: Text(AppLocalizations.of(context)!.showTextOnGridView),
|
||||
subtitle:
|
||||
Text(AppLocalizations.of(context)!.showTextOnGridViewSubtitle),
|
||||
value: FinampSettingsHelper.finampSettings.showTextOnGridView,
|
||||
onChanged: (value) =>
|
||||
FinampSettingsHelper.setShowTextOnGridView(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../../services/theme_mode_helper.dart';
|
||||
|
||||
extension LocalisedName on ThemeMode {
|
||||
String toLocalisedString(BuildContext context) =>
|
||||
_humanReadableLocalisedName(this, context);
|
||||
|
||||
String _humanReadableLocalisedName(
|
||||
ThemeMode themeMode, BuildContext context) {
|
||||
switch (themeMode) {
|
||||
case ThemeMode.system:
|
||||
return AppLocalizations.of(context)!.system;
|
||||
case ThemeMode.light:
|
||||
return AppLocalizations.of(context)!.light;
|
||||
case ThemeMode.dark:
|
||||
return AppLocalizations.of(context)!.dark;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ThemeSelector extends StatelessWidget {
|
||||
const ThemeSelector({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<Box<ThemeMode>>(
|
||||
valueListenable: ThemeModeHelper.themeModeListener,
|
||||
builder: (_, box, __) {
|
||||
return ListTile(
|
||||
title: const Text("Theme"),
|
||||
trailing: DropdownButton<ThemeMode>(
|
||||
value: box.get("ThemeMode"),
|
||||
items: ThemeMode.values
|
||||
.map((e) => DropdownMenuItem<ThemeMode>(
|
||||
value: e,
|
||||
child: Text(e.toLocalisedString(context)),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ThemeModeHelper.setThemeMode(value);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user