chore: style grid
This commit is contained in:
@@ -3,6 +3,10 @@ import 'package:flutter/material.dart';
|
||||
/// Log messages stored in the DB
|
||||
const int kLogMessageLimit = 500;
|
||||
|
||||
/// RenderList constants
|
||||
const int kRenderListBatchSize = 512;
|
||||
const int kRenderListOppositeBatchSize = 128;
|
||||
|
||||
/// Chunked asset sync size
|
||||
const int kFullSyncChunkSize = 10000;
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension AsynSnapShotState on AsyncSnapshot {
|
||||
bool get isWaiting => connectionState == ConnectionState.waiting;
|
||||
bool get isDone => connectionState == ConnectionState.done;
|
||||
}
|
||||
@@ -5,6 +5,12 @@ extension BuildContextHelper on BuildContext {
|
||||
/// Get the current [ThemeData] used
|
||||
ThemeData get theme => Theme.of(this);
|
||||
|
||||
/// Get the current [ColorScheme] used
|
||||
ColorScheme get colorScheme => theme.colorScheme;
|
||||
|
||||
/// Get the current [TextTheme] used
|
||||
TextTheme get textTheme => theme.textTheme;
|
||||
|
||||
/// Get the default [TextStyle]
|
||||
TextStyle get defaultTextStyle => DefaultTextStyle.of(this).style;
|
||||
|
||||
|
||||
@@ -12,21 +12,9 @@ import 'package:immich_mobile/utils/constants/globals.dart';
|
||||
import 'package:immich_mobile/utils/mixins/log_context.mixin.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
@immutable
|
||||
class ImApiClientData {
|
||||
final String endpoint;
|
||||
final Map<String, String> headersMap;
|
||||
|
||||
const ImApiClientData({required this.endpoint, required this.headersMap});
|
||||
}
|
||||
|
||||
class ImmichApiClient extends ApiClient with LogContext {
|
||||
ImmichApiClient({required String endpoint}) : super(basePath: endpoint);
|
||||
|
||||
/// Used to recreate the client in Isolates
|
||||
ImApiClientData get clientData =>
|
||||
ImApiClientData(endpoint: basePath, headersMap: defaultHeaderMap);
|
||||
|
||||
Map<String, String> get headers => defaultHeaderMap;
|
||||
|
||||
Future<void> init({String? accessToken}) async {
|
||||
@@ -49,15 +37,6 @@ class ImmichApiClient extends ApiClient with LogContext {
|
||||
addDefaultHeader(kImmichHeaderDeviceType, Platform.operatingSystem);
|
||||
}
|
||||
|
||||
factory ImmichApiClient.clientData(ImApiClientData data) {
|
||||
final client = ImmichApiClient(endpoint: data.endpoint);
|
||||
|
||||
for (final entry in data.headersMap.entries) {
|
||||
client.addDefaultHeader(entry.key, entry.value);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> invokeAPI(
|
||||
String path,
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/domain/repositories/database.repository.dart';
|
||||
import 'package:immich_mobile/service_locator.dart';
|
||||
import 'package:immich_mobile/utils/immich_api_client.dart';
|
||||
import 'package:immich_mobile/utils/log_manager.dart';
|
||||
|
||||
@immutable
|
||||
class _ImApiClientData {
|
||||
final String endpoint;
|
||||
final Map<String, String> headersMap;
|
||||
|
||||
const _ImApiClientData({required this.endpoint, required this.headersMap});
|
||||
}
|
||||
|
||||
class IsolateHelper {
|
||||
// Cache the ApiClient to reconstruct it later after inside the isolate
|
||||
late final _ImApiClientData? _clientData;
|
||||
|
||||
IsolateHelper();
|
||||
|
||||
void preIsolateHandling() {
|
||||
final apiClient = di<ImmichApiClient>();
|
||||
_clientData = _ImApiClientData(
|
||||
endpoint: apiClient.basePath,
|
||||
headersMap: apiClient.defaultHeaderMap,
|
||||
);
|
||||
}
|
||||
|
||||
void postIsolateHandling({required DriftDatabaseRepository database}) {
|
||||
assert(_clientData != null);
|
||||
// Reconstruct client from cached data
|
||||
final client = ImmichApiClient(endpoint: _clientData!.endpoint);
|
||||
for (final entry in _clientData.headersMap.entries) {
|
||||
client.addDefaultHeader(entry.key, entry.value);
|
||||
}
|
||||
|
||||
// Register all services in the isolates memory
|
||||
ServiceLocator.configureServicesForIsolate(
|
||||
database: database,
|
||||
apiClient: client,
|
||||
);
|
||||
|
||||
// Init log manager to continue listening to log events
|
||||
LogManager.I.init();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user