add adaptive_scaffold

This commit is contained in:
shenlong-tanwen
2024-05-24 09:42:02 +05:30
parent fb6253d2d1
commit 1631df70e9
295 changed files with 2540 additions and 44480 deletions
@@ -0,0 +1,31 @@
import 'package:flutter/foundation.dart';
@immutable
class LocalAlbum {
final int id;
final String localId;
final String name;
final DateTime modifiedTime;
const LocalAlbum({
required this.id,
required this.localId,
required this.name,
required this.modifiedTime,
});
@override
bool operator ==(covariant LocalAlbum other) {
if (identical(this, other)) return true;
return other.hashCode == hashCode;
}
@override
int get hashCode {
return id.hashCode ^
localId.hashCode ^
name.hashCode ^
modifiedTime.hashCode;
}
}
@@ -1,10 +1,15 @@
import 'package:flutter/material.dart';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/presentation/modules/theme/models/app_theme.model.dart';
enum AppSettings<T> {
appTheme<int>(StoreKey.appTheme, 10);
enum AppSetting<T> {
appTheme<AppTheme>(StoreKey.appTheme, AppTheme.blue),
themeMode<ThemeMode>(StoreKey.themeMode, ThemeMode.system),
darkMode<bool>(StoreKey.darkMode, false);
const AppSettings(this.storeKey, this.defaultValue);
const AppSetting(this.storeKey, this.defaultValue);
final StoreKey storeKey;
// ignore: avoid-dynamic
final StoreKey<T, dynamic> storeKey;
final T defaultValue;
}
@@ -0,0 +1,82 @@
import 'package:flutter/foundation.dart';
enum AssetType {
// do not change this order!
other,
image,
video,
audio,
}
@immutable
class LocalAsset {
final int id;
final String localId;
final String name;
final String checksum;
final int height;
final int width;
final AssetType type;
final DateTime createdTime;
final DateTime modifiedTime;
final int duration;
final bool isLivePhoto;
const LocalAsset({
required this.id,
required this.localId,
required this.name,
required this.checksum,
required this.height,
required this.width,
required this.type,
required this.createdTime,
required this.modifiedTime,
required this.duration,
required this.isLivePhoto,
});
@override
String toString() {
return 'LocalAsset(id: $id, localId: $localId, name: $name, checksum: $checksum, height: $height, width: $width, type: $type, createdTime: $createdTime, modifiedTime: $modifiedTime, duration: $duration, isLivePhoto: $isLivePhoto)';
}
String toJSON() {
return """
{
"id": $id,
"localId": "$localId",
"name": "$name",
"checksum": "$checksum",
"height": $height,
"width": $width,
"type": "$type",
"createdTime": "$createdTime",
"modifiedTime": "$modifiedTime",
"duration": "$duration",
"isLivePhoto": "$isLivePhoto",
}""";
}
@override
bool operator ==(covariant LocalAsset other) {
if (identical(this, other)) return true;
return other.hashCode == hashCode;
}
@override
int get hashCode {
return id.hashCode ^
localId.hashCode ^
name.hashCode ^
checksum.hashCode ^
height.hashCode ^
width.hashCode ^
type.hashCode ^
createdTime.hashCode ^
modifiedTime.hashCode ^
duration.hashCode ^
isLivePhoto.hashCode;
}
}
@@ -1,7 +1,9 @@
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
/// Log levels according to dart logging [Level]
enum LogLevel {
// do not change this order!
all,
finest,
finer,
@@ -20,6 +22,7 @@ extension LevelExtension on Level {
LogLevel.info;
}
@immutable
class LogMessage {
final int id;
final String content;
@@ -0,0 +1,34 @@
import 'package:openapi/openapi.dart';
class ServerConfig {
final String? oauthButtonText;
const ServerConfig({this.oauthButtonText});
ServerConfig copyWith({String? oauthButtonText}) {
return ServerConfig(
oauthButtonText: oauthButtonText ?? this.oauthButtonText,
);
}
factory ServerConfig.fromDto(ServerConfigDto dto) => ServerConfig(
oauthButtonText:
dto.oauthButtonText.isEmpty ? null : dto.oauthButtonText,
);
const ServerConfig.reset() : oauthButtonText = null;
@override
String toString() =>
'ServerConfig(oauthButtonText: ${oauthButtonText ?? '<NULL>'})';
@override
bool operator ==(covariant ServerConfig other) {
if (identical(this, other)) return true;
return other.oauthButtonText == oauthButtonText;
}
@override
int get hashCode => oauthButtonText.hashCode;
}
@@ -0,0 +1,37 @@
import 'package:immich_mobile/domain/models/server-info/server_config.model.dart';
import 'package:immich_mobile/domain/models/server-info/server_features.model.dart';
class ServerFeatureConfig {
final ServerFeatures features;
final ServerConfig config;
const ServerFeatureConfig({required this.features, required this.config});
ServerFeatureConfig copyWith({
ServerFeatures? features,
ServerConfig? config,
}) {
return ServerFeatureConfig(
features: features ?? this.features,
config: config ?? this.config,
);
}
const ServerFeatureConfig.reset()
: features = const ServerFeatures.reset(),
config = const ServerConfig.reset();
@override
String toString() =>
'ServerFeatureConfig(features: $features, config: $config)';
@override
bool operator ==(covariant ServerFeatureConfig other) {
if (identical(this, other)) return true;
return other.features == features && other.config == config;
}
@override
int get hashCode => features.hashCode ^ config.hashCode;
}
@@ -0,0 +1,42 @@
import 'package:openapi/openapi.dart';
class ServerFeatures {
final bool hasPasswordLogin;
final bool hasOAuthLogin;
const ServerFeatures({
required this.hasPasswordLogin,
required this.hasOAuthLogin,
});
ServerFeatures copyWith({bool? hasPasswordLogin, bool? hasOAuthLogin}) {
return ServerFeatures(
hasPasswordLogin: hasPasswordLogin ?? this.hasPasswordLogin,
hasOAuthLogin: hasOAuthLogin ?? this.hasOAuthLogin,
);
}
factory ServerFeatures.fromDto(ServerFeaturesDto dto) => ServerFeatures(
hasPasswordLogin: dto.passwordLogin,
hasOAuthLogin: dto.oauth,
);
const ServerFeatures.reset()
: hasPasswordLogin = true,
hasOAuthLogin = false;
@override
String toString() =>
'ServerFeatures(hasPasswordLogin: $hasPasswordLogin, hasOAuthLogin: $hasOAuthLogin)';
@override
bool operator ==(covariant ServerFeatures other) {
if (identical(this, other)) return true;
return other.hasPasswordLogin == hasPasswordLogin &&
other.hasOAuthLogin == hasOAuthLogin;
}
@override
int get hashCode => hasPasswordLogin.hashCode ^ hasOAuthLogin.hashCode;
}
+37 -54
View File
@@ -1,19 +1,14 @@
/// Key for each possible value in the `Store`.
/// Defines the data type for each value
enum StoreKey {
appTheme(1000, type: int);
import 'package:flutter/material.dart';
import 'package:immich_mobile/domain/interfaces/store.interface.dart';
import 'package:immich_mobile/domain/utils/store_converters.dart';
import 'package:immich_mobile/presentation/modules/theme/models/app_theme.model.dart';
const StoreKey(this.id, {required this.type});
@immutable
class StoreValue<T> {
final int id;
final Type type;
}
final T? value;
class StoreValue {
final int id;
final int? intValue;
final String? stringValue;
const StoreValue({required this.id, this.intValue, this.stringValue});
const StoreValue({required this.id, this.value});
@override
bool operator ==(covariant StoreValue other) {
@@ -23,45 +18,33 @@ class StoreValue {
}
@override
int get hashCode => id.hashCode ^ intValue.hashCode ^ stringValue.hashCode;
T? extract<T>(Type type) {
switch (type) {
case const (int):
return intValue as T?;
case const (bool):
return intValue == null ? null : (intValue! == 1) as T;
case const (DateTime):
return intValue == null
? null
: DateTime.fromMicrosecondsSinceEpoch(intValue!) as T;
case const (String):
return stringValue as T?;
default:
throw UnsupportedError("Unknown Store Key type");
}
}
static StoreValue of<T>(StoreKey key, T? value) {
int? i;
String? s;
switch (key.type) {
case const (int):
i = value as int?;
break;
case const (bool):
i = value == null ? null : (value == true ? 1 : 0);
break;
case const (DateTime):
i = value == null ? null : (value as DateTime).microsecondsSinceEpoch;
break;
case const (String):
s = value as String?;
break;
default:
throw UnsupportedError("Unknown Store Key type");
}
return StoreValue(id: key.id, intValue: i, stringValue: s);
}
int get hashCode => id.hashCode ^ value.hashCode;
}
/// Key for each possible value in the `Store`.
/// Also stores the converter to convert the value to and from the store and the type of value stored in the Store
enum StoreKey<T, U> {
serverEndpoint<String, String>(
0,
converter: StorePrimitiveConverter(),
type: String,
),
appTheme<AppTheme, int>(
1000,
converter: StoreEnumConverter(AppTheme.values),
type: int,
),
themeMode<ThemeMode, int>(
1001,
converter: StoreEnumConverter(ThemeMode.values),
type: int,
),
darkMode<bool, int>(1002, converter: StoreBooleanConverter(), type: int);
const StoreKey(this.id, {required this.converter, required this.type});
final int id;
/// Type is also stored here easily fetch it during runtime
final Type type;
final IStoreConverter<T, U> converter;
}