refactor: DCM - const border radius, constructor & switch expressions (#19515)

* enable border radius, switch exp, const constructor

* regenerate provider

* more formatting

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong
2025-06-25 13:06:24 +05:30
committed by GitHub
parent 05064f87f0
commit 5b0575b956
130 changed files with 338 additions and 264 deletions
@@ -100,6 +100,7 @@ enum AppSettingsEnum<T> {
}
class AppSettingsService {
const AppSettingsService();
T getSetting<T>(AppSettingsEnum<T> setting) {
return Store.get(setting.storeKey, setting.defaultValue);
}
@@ -9,7 +9,7 @@ final backupAlbumServiceProvider = Provider<BackupAlbumService>((ref) {
class BackupAlbumService {
final BackupAlbumRepository _backupAlbumRepository;
BackupAlbumService(this._backupAlbumRepository);
const BackupAlbumService(this._backupAlbumRepository);
Future<List<BackupAlbum>> getAll({BackupAlbumSort? sort}) {
return _backupAlbumRepository.getAll(sort: sort);
+10 -14
View File
@@ -25,7 +25,7 @@ class DeepLinkService {
final CurrentAsset _currentAsset;
final CurrentAlbum _currentAlbum;
DeepLinkService(
const DeepLinkService(
this._memoryService,
this._assetService,
this._albumService,
@@ -38,16 +38,12 @@ class DeepLinkService {
final intent = link.uri.host;
final queryParams = link.uri.queryParameters;
PageRouteInfo<dynamic>? deepLinkRoute;
switch (intent) {
case "memory":
deepLinkRoute = await _buildMemoryDeepLink(queryParams['id'] ?? '');
case "asset":
deepLinkRoute = await _buildAssetDeepLink(queryParams['id'] ?? '');
case "album":
deepLinkRoute = await _buildAlbumDeepLink(queryParams['id'] ?? '');
}
PageRouteInfo<dynamic>? deepLinkRoute = switch (intent) {
"memory" => await _buildMemoryDeepLink(queryParams['id'] ?? ''),
"asset" => await _buildAssetDeepLink(queryParams['id'] ?? ''),
"album" => await _buildAlbumDeepLink(queryParams['id'] ?? ''),
_ => null,
};
// Deep link resolution failed, safely handle it based on the app state
if (deepLinkRoute == null) {
@@ -98,7 +94,7 @@ class DeepLinkService {
]);
}
Future<MemoryRoute?> _buildMemoryDeepLink(String memoryId) async {
Future<PageRouteInfo?> _buildMemoryDeepLink(String memoryId) async {
final memory = await _memoryService.getMemoryById(memoryId);
if (memory == null) {
@@ -108,7 +104,7 @@ class DeepLinkService {
return MemoryRoute(memories: [memory], memoryIndex: 0);
}
Future<GalleryViewerRoute?> _buildAssetDeepLink(String assetId) async {
Future<PageRouteInfo?> _buildAssetDeepLink(String assetId) async {
final asset = await _assetService.getAssetByRemoteId(assetId);
if (asset == null) {
@@ -126,7 +122,7 @@ class DeepLinkService {
);
}
Future<AlbumViewerRoute?> _buildAlbumDeepLink(String albumId) async {
Future<PageRouteInfo?> _buildAlbumDeepLink(String albumId) async {
final album = await _albumService.getAlbumByRemoteId(albumId);
if (album == null) {
+2 -2
View File
@@ -3,10 +3,10 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/entities/store.entity.dart';
final deviceServiceProvider = Provider((ref) => DeviceService());
final deviceServiceProvider = Provider((ref) => const DeviceService());
class DeviceService {
DeviceService();
const DeviceService();
createDeviceId() {
return FlutterUdid.consistentUdid;
+1 -1
View File
@@ -8,7 +8,7 @@ import 'package:immich_mobile/repositories/asset.repository.dart';
class EntityService {
final AssetRepository _assetRepository;
final IsarUserRepository _isarUserRepository;
EntityService(
const EntityService(
this._assetRepository,
this._isarUserRepository,
);
+1 -1
View File
@@ -7,7 +7,7 @@ final etagServiceProvider =
class ETagService {
final ETagRepository _eTagRepository;
ETagService(this._eTagRepository);
const ETagService(this._eTagRepository);
Future<void> clearTable() {
return _eTagRepository.clearTable();
+1 -1
View File
@@ -11,7 +11,7 @@ final localAuthServiceProvider = Provider(
class LocalAuthService {
final BiometricRepository _biometricRepository;
LocalAuthService(this._biometricRepository);
const LocalAuthService(this._biometricRepository);
Future<BiometricStatus> getStatus() {
return _biometricRepository.getStatus();
@@ -3,10 +3,11 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:logging/logging.dart';
final localFileManagerServiceProvider = Provider<LocalFilesManagerService>(
(ref) => LocalFilesManagerService(),
(ref) => const LocalFilesManagerService(),
);
class LocalFilesManagerService {
const LocalFilesManagerService();
static final Logger _logger = Logger('LocalFilesManager');
static const MethodChannel _channel = MethodChannel('file_trash');
+1 -1
View File
@@ -13,7 +13,7 @@ class NetworkService {
final NetworkRepository _repository;
final IPermissionRepository _permissionRepository;
NetworkService(this._repository, this._permissionRepository);
const NetworkService(this._repository, this._permissionRepository);
Future<bool> getLocationWhenInUserPermission() {
return _permissionRepository.hasLocationWhenInUsePermission();
@@ -10,7 +10,7 @@ final secureStorageServiceProvider = Provider(
class SecureStorageService {
final SecureStorageRepository _secureStorageRepository;
SecureStorageService(this._secureStorageRepository);
const SecureStorageService(this._secureStorageRepository);
Future<void> write(String key, String value) async {
await _secureStorageRepository.write(key, value);
+1 -1
View File
@@ -16,7 +16,7 @@ final serverInfoServiceProvider = Provider(
class ServerInfoService {
final ApiService _apiService;
ServerInfoService(this._apiService);
const ServerInfoService(this._apiService);
Future<ServerDiskInfo?> getDiskInfo() async {
try {
+1 -1
View File
@@ -7,7 +7,7 @@ import 'package:immich_mobile/services/api.service.dart';
import 'package:openapi/api.dart';
class StackService {
StackService(this._api, this._assetRepository);
const StackService(this._api, this._assetRepository);
final ApiService _api;
final AssetRepository _assetRepository;
+1 -1
View File
@@ -11,7 +11,7 @@ final widgetServiceProvider = Provider((ref) {
class WidgetService {
final WidgetRepository _repository;
WidgetService(this._repository);
const WidgetService(this._repository);
Future<void> writeCredentials(String serverURL, String sessionKey) async {
await _repository.setAppGroupId(appShareGroupId);