opt.: OS type
This commit is contained in:
@@ -35,7 +35,7 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
||||
|
||||
final newest = update.build.last.current;
|
||||
if (newest == null) {
|
||||
Loggers.app.warning('Update not available on $platform');
|
||||
Loggers.app.warning('Update not available on ${OS.type}');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
enum PlatformType {
|
||||
enum OS {
|
||||
android,
|
||||
ios,
|
||||
linux,
|
||||
@@ -12,32 +12,60 @@ enum PlatformType {
|
||||
fuchsia,
|
||||
unknown;
|
||||
|
||||
String get prettyName {
|
||||
static final _os = () {
|
||||
if (kIsWeb) {
|
||||
return OS.web;
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
return OS.android;
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
return OS.ios;
|
||||
}
|
||||
if (Platform.isLinux) {
|
||||
return OS.linux;
|
||||
}
|
||||
if (Platform.isMacOS) {
|
||||
return OS.macos;
|
||||
}
|
||||
if (Platform.isWindows) {
|
||||
return OS.windows;
|
||||
}
|
||||
if (Platform.isFuchsia) {
|
||||
return OS.fuchsia;
|
||||
}
|
||||
return OS.unknown;
|
||||
}();
|
||||
|
||||
static OS get type => _os;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
switch (this) {
|
||||
case PlatformType.android:
|
||||
case OS.android:
|
||||
return 'Android';
|
||||
case PlatformType.ios:
|
||||
case OS.ios:
|
||||
return 'iOS';
|
||||
case PlatformType.linux:
|
||||
case OS.linux:
|
||||
return 'Linux';
|
||||
case PlatformType.macos:
|
||||
case OS.macos:
|
||||
return 'macOS';
|
||||
case PlatformType.windows:
|
||||
case OS.windows:
|
||||
return 'Windows';
|
||||
case PlatformType.web:
|
||||
case OS.web:
|
||||
return 'Web';
|
||||
case PlatformType.fuchsia:
|
||||
case OS.fuchsia:
|
||||
return 'Fuchsia';
|
||||
case PlatformType.unknown:
|
||||
case OS.unknown:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether has platform specific settings.
|
||||
bool get hasSettings {
|
||||
switch (this) {
|
||||
case PlatformType.android:
|
||||
case PlatformType.ios:
|
||||
static bool get hasSettings {
|
||||
switch (type) {
|
||||
case OS.android:
|
||||
case OS.ios:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -45,41 +73,16 @@ enum PlatformType {
|
||||
}
|
||||
}
|
||||
|
||||
final _p = () {
|
||||
if (kIsWeb) {
|
||||
return PlatformType.web;
|
||||
}
|
||||
if (Platform.isAndroid) {
|
||||
return PlatformType.android;
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
return PlatformType.ios;
|
||||
}
|
||||
if (Platform.isLinux) {
|
||||
return PlatformType.linux;
|
||||
}
|
||||
if (Platform.isMacOS) {
|
||||
return PlatformType.macos;
|
||||
}
|
||||
if (Platform.isWindows) {
|
||||
return PlatformType.windows;
|
||||
}
|
||||
if (Platform.isFuchsia) {
|
||||
return PlatformType.fuchsia;
|
||||
}
|
||||
return PlatformType.unknown;
|
||||
}();
|
||||
|
||||
PlatformType get platform => _p;
|
||||
|
||||
bool get isAndroid => _p == PlatformType.android;
|
||||
bool get isIOS => _p == PlatformType.ios;
|
||||
bool get isLinux => _p == PlatformType.linux;
|
||||
bool get isMacOS => _p == PlatformType.macos;
|
||||
bool get isWindows => _p == PlatformType.windows;
|
||||
bool get isWeb => _p == PlatformType.web;
|
||||
bool get isMobile => _p == PlatformType.ios || _p == PlatformType.android;
|
||||
bool get isAndroid => OS.type == OS.android;
|
||||
bool get isIOS => OS.type == OS.ios;
|
||||
bool get isLinux => OS.type == OS.linux;
|
||||
bool get isMacOS => OS.type == OS.macos;
|
||||
bool get isWindows => OS.type == OS.windows;
|
||||
bool get isWeb => OS.type == OS.web;
|
||||
bool get isMobile =>
|
||||
OS.type == OS.ios ||
|
||||
OS.type == OS.android;
|
||||
bool get isDesktop =>
|
||||
_p == PlatformType.linux ||
|
||||
_p == PlatformType.macos ||
|
||||
_p == PlatformType.windows;
|
||||
OS.type == OS.linux ||
|
||||
OS.type == OS.macos ||
|
||||
OS.type == OS.windows;
|
||||
|
||||
@@ -112,12 +112,12 @@ class AppUpdatePlatformSpecific<T> {
|
||||
};
|
||||
|
||||
T? get current {
|
||||
switch (platform) {
|
||||
case PlatformType.macos:
|
||||
switch (OS.type) {
|
||||
case OS.macos:
|
||||
return mac;
|
||||
case PlatformType.ios:
|
||||
case OS.ios:
|
||||
return ios;
|
||||
case PlatformType.android:
|
||||
case OS.android:
|
||||
return android;
|
||||
default:
|
||||
return null;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 562;
|
||||
static const int build = 563;
|
||||
static const String engine = "3.13.2";
|
||||
static const String buildAt = "2023-09-17 00:26:50";
|
||||
static const int modifications = 2;
|
||||
static const String buildAt = "2023-09-17 14:30:45";
|
||||
static const int modifications = 3;
|
||||
static const int script = 15;
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
}
|
||||
|
||||
Widget _buildNetSpeedTop() {
|
||||
const icon = Icon(Icons.arrow_downward, size: 17);
|
||||
const icon = Icon(Icons.arrow_downward, size: 13);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 3),
|
||||
child: Row(
|
||||
|
||||
@@ -181,9 +181,10 @@ class _SettingPageState extends State<SettingPage> {
|
||||
if (BioAuth.isPlatformSupported) {
|
||||
children.add(_buildBioAuth());
|
||||
}
|
||||
|
||||
/// Platform specific settings
|
||||
if (platform.hasSettings) {
|
||||
children.add(_buildPlatformSetting(platform));
|
||||
if (OS.hasSettings) {
|
||||
children.add(_buildPlatformSetting());
|
||||
}
|
||||
return Column(
|
||||
children: children.map((e) => RoundRectCard(e)).toList(),
|
||||
@@ -1038,16 +1039,16 @@ class _SettingPageState extends State<SettingPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlatformSetting(PlatformType type) {
|
||||
Widget _buildPlatformSetting() {
|
||||
return ListTile(
|
||||
title: Text('${type.prettyName} ${_s.setting}'),
|
||||
title: Text('${OS.type} ${_s.setting}'),
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
onTap: () {
|
||||
switch (type) {
|
||||
case PlatformType.android:
|
||||
switch (OS.type) {
|
||||
case OS.android:
|
||||
AppRoute.androidSettings().go(context);
|
||||
break;
|
||||
case PlatformType.ios:
|
||||
case OS.ios:
|
||||
AppRoute.iosSettings().go(context);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user