Display mode

This commit is contained in:
exttex 2021-03-21 22:46:44 +01:00
parent 46f3aa30da
commit 3105ed6c1d
8 changed files with 52 additions and 2 deletions

View File

@ -348,6 +348,9 @@ const language_en_us = {
"Email": "Email",
"Missing email or password!": "Missing email or password!",
"Error logging in using email, please check your credentials.\nError:": "Error logging in using email, please check your credentials.\nError:",
"Error logging in!": "Error logging in!"
"Error logging in!": "Error logging in!",
"Change display mode": "Change display mode",
"Enable high refresh rates": "Enable high refresh rates",
"Display mode": "Display mode"
}
};

View File

@ -5,6 +5,7 @@ import 'package:custom_navigator/custom_navigator.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:freezer/api/cache.dart';
import 'package:freezer/api/definitions.dart';
@ -175,6 +176,13 @@ class _MainScreenState extends State<MainScreen> with SingleTickerProviderStateM
void initState() {
navigatorKey = GlobalKey<NavigatorState>();
//Set display mode
if (settings.displayMode != null) {
FlutterDisplayMode.supported.then((modes) async {
FlutterDisplayMode.setMode(modes[settings.displayMode]);
});
}
_startStreamingServer();
//Start with parameters

View File

@ -97,6 +97,8 @@ class Settings {
String font;
@JsonKey(defaultValue: false)
bool lyricsVisualizer;
@JsonKey(defaultValue: null)
int displayMode;
//Colors
@JsonKey(toJson: _colorToJson, fromJson: _colorFromJson)

View File

@ -68,6 +68,7 @@ Settings _$SettingsFromJson(Map<String, dynamic> json) {
..blurPlayerBackground = json['blurPlayerBackground'] as bool ?? false
..font = json['font'] as String ?? 'Deezer'
..lyricsVisualizer = json['lyricsVisualizer'] as bool ?? false
..displayMode = json['displayMode'] as int
..primaryColor = Settings._colorFromJson(json['primaryColor'] as int)
..useArtColor = json['useArtColor'] as bool ?? false
..deezerLanguage = json['deezerLanguage'] as String ?? 'en'
@ -109,6 +110,7 @@ Map<String, dynamic> _$SettingsToJson(Settings instance) => <String, dynamic>{
'blurPlayerBackground': instance.blurPlayerBackground,
'font': instance.font,
'lyricsVisualizer': instance.lyricsVisualizer,
'displayMode': instance.displayMode,
'primaryColor': Settings._colorToJson(instance.primaryColor),
'useArtColor': instance.useArtColor,
'deezerLanguage': instance.deezerLanguage,

View File

@ -344,7 +344,7 @@ class _EmailLoginState extends State<EmailLogin> {
String _password;
bool _loading = false;
void _login() async {
Future _login() async {
setState(() => _loading = true);
//Try logging in
String arl;

View File

@ -5,6 +5,7 @@ import 'package:filesize/filesize.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:fluttericon/web_symbols_icons.dart';
@ -329,6 +330,32 @@ class _AppearanceSettingsState extends State<AppearanceSettings> {
value: settings.useArtColor,
onChanged: (v) => setState(() => settings.updateUseArtColor(v)),
),
),
//Display mode
ListTile(
leading: Icon(Icons.screen_lock_portrait),
title: Text('Change display mode'.i18n),
subtitle: Text('Enable high refresh rates'.i18n),
onTap: () async {
List modes = await FlutterDisplayMode.supported;
showDialog(
context: context,
builder: (context) {
return SimpleDialog(
title: Text('Display mode'.i18n),
children: List.generate(modes.length, (i) => SimpleDialogOption(
child: Text(modes[i].toString()),
onPressed: () async {
settings.displayMode = i;
await settings.save();
await FlutterDisplayMode.setMode(modes[i]);
Navigator.of(context).pop();
},
))
);
}
);
},
)
],
),

View File

@ -351,6 +351,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.2"
flutter_displaymode:
dependency: "direct main"
description:
name: flutter_displaymode
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
flutter_inappwebview:
dependency: "direct main"
description:

View File

@ -27,6 +27,7 @@ dependencies:
flutter_localizations:
sdk: flutter
flutter_displaymode: ^0.1.1
crypto: ^2.1.5
http: ^0.12.2
cookie_jar: ^1.0.1