mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
Refactor mobile to use OpenApi generated SDK (#336)
This commit is contained in:
parent
d69470e207
commit
ae7e582ec8
276 changed files with 14513 additions and 3003 deletions
|
|
@ -1,100 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class DeviceInfoRemote {
|
||||
final int id;
|
||||
final String userId;
|
||||
final String deviceId;
|
||||
final String deviceType;
|
||||
final String notificationToken;
|
||||
final String createdAt;
|
||||
final bool isAutoBackup;
|
||||
|
||||
DeviceInfoRemote({
|
||||
required this.id,
|
||||
required this.userId,
|
||||
required this.deviceId,
|
||||
required this.deviceType,
|
||||
required this.notificationToken,
|
||||
required this.createdAt,
|
||||
required this.isAutoBackup,
|
||||
});
|
||||
|
||||
DeviceInfoRemote copyWith({
|
||||
int? id,
|
||||
String? userId,
|
||||
String? deviceId,
|
||||
String? deviceType,
|
||||
String? notificationToken,
|
||||
String? createdAt,
|
||||
bool? isAutoBackup,
|
||||
}) {
|
||||
return DeviceInfoRemote(
|
||||
id: id ?? this.id,
|
||||
userId: userId ?? this.userId,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
deviceType: deviceType ?? this.deviceType,
|
||||
notificationToken: notificationToken ?? this.notificationToken,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
isAutoBackup: isAutoBackup ?? this.isAutoBackup,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'userId': userId,
|
||||
'deviceId': deviceId,
|
||||
'deviceType': deviceType,
|
||||
'notificationToken': notificationToken,
|
||||
'createdAt': createdAt,
|
||||
'isAutoBackup': isAutoBackup,
|
||||
};
|
||||
}
|
||||
|
||||
factory DeviceInfoRemote.fromMap(Map<String, dynamic> map) {
|
||||
return DeviceInfoRemote(
|
||||
id: map['id']?.toInt() ?? 0,
|
||||
userId: map['userId'] ?? '',
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
deviceType: map['deviceType'] ?? '',
|
||||
notificationToken: map['notificationToken'] ?? '',
|
||||
createdAt: map['createdAt'] ?? '',
|
||||
isAutoBackup: map['isAutoBackup'] ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory DeviceInfoRemote.fromJson(String source) =>
|
||||
DeviceInfoRemote.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DeviceInfo(id: $id, userId: $userId, deviceId: $deviceId, deviceType: $deviceType, notificationToken: $notificationToken, createdAt: $createdAt, isAutoBackup: $isAutoBackup)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is DeviceInfoRemote &&
|
||||
other.id == id &&
|
||||
other.userId == userId &&
|
||||
other.deviceId == deviceId &&
|
||||
other.deviceType == deviceType &&
|
||||
other.notificationToken == notificationToken &&
|
||||
other.createdAt == createdAt &&
|
||||
other.isAutoBackup == isAutoBackup;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
userId.hashCode ^
|
||||
deviceId.hashCode ^
|
||||
deviceType.hashCode ^
|
||||
notificationToken.hashCode ^
|
||||
createdAt.hashCode ^
|
||||
isAutoBackup.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class ImmichExif {
|
||||
final int? id;
|
||||
final String? assetId;
|
||||
final String? make;
|
||||
final String? model;
|
||||
final String? imageName;
|
||||
final int? exifImageWidth;
|
||||
final int? exifImageHeight;
|
||||
final int? fileSizeInByte;
|
||||
final String? orientation;
|
||||
final String? dateTimeOriginal;
|
||||
final String? modifyDate;
|
||||
final String? lensModel;
|
||||
final double? fNumber;
|
||||
final double? focalLength;
|
||||
final int? iso;
|
||||
final double? exposureTime;
|
||||
final double? latitude;
|
||||
final double? longitude;
|
||||
final String? city;
|
||||
final String? state;
|
||||
final String? country;
|
||||
|
||||
ImmichExif({
|
||||
this.id,
|
||||
this.assetId,
|
||||
this.make,
|
||||
this.model,
|
||||
this.imageName,
|
||||
this.exifImageWidth,
|
||||
this.exifImageHeight,
|
||||
this.fileSizeInByte,
|
||||
this.orientation,
|
||||
this.dateTimeOriginal,
|
||||
this.modifyDate,
|
||||
this.lensModel,
|
||||
this.fNumber,
|
||||
this.focalLength,
|
||||
this.iso,
|
||||
this.exposureTime,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.city,
|
||||
this.state,
|
||||
this.country,
|
||||
});
|
||||
|
||||
ImmichExif copyWith({
|
||||
int? id,
|
||||
String? assetId,
|
||||
String? make,
|
||||
String? model,
|
||||
String? imageName,
|
||||
int? exifImageWidth,
|
||||
int? exifImageHeight,
|
||||
int? fileSizeInByte,
|
||||
String? orientation,
|
||||
String? dateTimeOriginal,
|
||||
String? modifyDate,
|
||||
String? lensModel,
|
||||
double? fNumber,
|
||||
double? focalLength,
|
||||
int? iso,
|
||||
double? exposureTime,
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
String? city,
|
||||
String? state,
|
||||
String? country,
|
||||
}) {
|
||||
return ImmichExif(
|
||||
id: id ?? this.id,
|
||||
assetId: assetId ?? this.assetId,
|
||||
make: make ?? this.make,
|
||||
model: model ?? this.model,
|
||||
imageName: imageName ?? this.imageName,
|
||||
exifImageWidth: exifImageWidth ?? this.exifImageWidth,
|
||||
exifImageHeight: exifImageHeight ?? this.exifImageHeight,
|
||||
fileSizeInByte: fileSizeInByte ?? this.fileSizeInByte,
|
||||
orientation: orientation ?? this.orientation,
|
||||
dateTimeOriginal: dateTimeOriginal ?? this.dateTimeOriginal,
|
||||
modifyDate: modifyDate ?? this.modifyDate,
|
||||
lensModel: lensModel ?? this.lensModel,
|
||||
fNumber: fNumber ?? this.fNumber,
|
||||
focalLength: focalLength ?? this.focalLength,
|
||||
iso: iso ?? this.iso,
|
||||
exposureTime: exposureTime ?? this.exposureTime,
|
||||
latitude: latitude ?? this.latitude,
|
||||
longitude: longitude ?? this.longitude,
|
||||
city: city ?? this.city,
|
||||
state: state ?? this.state,
|
||||
country: country ?? this.country,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'assetId': assetId,
|
||||
'make': make,
|
||||
'model': model,
|
||||
'imageName': imageName,
|
||||
'exifImageWidth': exifImageWidth,
|
||||
'exifImageHeight': exifImageHeight,
|
||||
'fileSizeInByte': fileSizeInByte,
|
||||
'orientation': orientation,
|
||||
'dateTimeOriginal': dateTimeOriginal,
|
||||
'modifyDate': modifyDate,
|
||||
'lensModel': lensModel,
|
||||
'fNumber': fNumber,
|
||||
'focalLength': focalLength,
|
||||
'iso': iso,
|
||||
'exposureTime': exposureTime,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'city': city,
|
||||
'state': state,
|
||||
'country': country,
|
||||
};
|
||||
}
|
||||
|
||||
factory ImmichExif.fromMap(Map<String, dynamic> map) {
|
||||
return ImmichExif(
|
||||
id: map['id']?.toInt(),
|
||||
assetId: map['assetId'],
|
||||
make: map['make'],
|
||||
model: map['model'],
|
||||
imageName: map['imageName'],
|
||||
exifImageWidth: map['exifImageWidth']?.toInt(),
|
||||
exifImageHeight: map['exifImageHeight']?.toInt(),
|
||||
fileSizeInByte: map['fileSizeInByte']?.toInt(),
|
||||
orientation: map['orientation'],
|
||||
dateTimeOriginal: map['dateTimeOriginal'],
|
||||
modifyDate: map['modifyDate'],
|
||||
lensModel: map['lensModel'],
|
||||
fNumber: map['fNumber']?.toDouble(),
|
||||
focalLength: map['focalLength']?.toDouble(),
|
||||
iso: map['iso']?.toInt(),
|
||||
exposureTime: map['exposureTime']?.toDouble(),
|
||||
latitude: map['latitude']?.toDouble(),
|
||||
longitude: map['longitude']?.toDouble(),
|
||||
city: map['city'],
|
||||
state: map['state'],
|
||||
country: map['country'],
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ImmichExif.fromJson(String source) =>
|
||||
ImmichExif.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ImmichExif(id: $id, assetId: $assetId, make: $make, model: $model, imageName: $imageName, exifImageWidth: $exifImageWidth, exifImageHeight: $exifImageHeight, fileSizeInByte: $fileSizeInByte, orientation: $orientation, dateTimeOriginal: $dateTimeOriginal, modifyDate: $modifyDate, lensModel: $lensModel, fNumber: $fNumber, focalLength: $focalLength, iso: $iso, exposureTime: $exposureTime, latitude: $latitude, longitude: $longitude, city: $city, state: $state, country: $country)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ImmichExif &&
|
||||
other.id == id &&
|
||||
other.assetId == assetId &&
|
||||
other.make == make &&
|
||||
other.model == model &&
|
||||
other.imageName == imageName &&
|
||||
other.exifImageWidth == exifImageWidth &&
|
||||
other.exifImageHeight == exifImageHeight &&
|
||||
other.fileSizeInByte == fileSizeInByte &&
|
||||
other.orientation == orientation &&
|
||||
other.dateTimeOriginal == dateTimeOriginal &&
|
||||
other.modifyDate == modifyDate &&
|
||||
other.lensModel == lensModel &&
|
||||
other.fNumber == fNumber &&
|
||||
other.focalLength == focalLength &&
|
||||
other.iso == iso &&
|
||||
other.exposureTime == exposureTime &&
|
||||
other.latitude == latitude &&
|
||||
other.longitude == longitude &&
|
||||
other.city == city &&
|
||||
other.state == state &&
|
||||
other.country == country;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
assetId.hashCode ^
|
||||
make.hashCode ^
|
||||
model.hashCode ^
|
||||
imageName.hashCode ^
|
||||
exifImageWidth.hashCode ^
|
||||
exifImageHeight.hashCode ^
|
||||
fileSizeInByte.hashCode ^
|
||||
orientation.hashCode ^
|
||||
dateTimeOriginal.hashCode ^
|
||||
modifyDate.hashCode ^
|
||||
lensModel.hashCode ^
|
||||
fNumber.hashCode ^
|
||||
focalLength.hashCode ^
|
||||
iso.hashCode ^
|
||||
exposureTime.hashCode ^
|
||||
latitude.hashCode ^
|
||||
longitude.hashCode ^
|
||||
city.hashCode ^
|
||||
state.hashCode ^
|
||||
country.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class ImmichAsset extends Equatable {
|
||||
final String id;
|
||||
final String deviceAssetId;
|
||||
final String userId;
|
||||
final String deviceId;
|
||||
final String type;
|
||||
final String createdAt;
|
||||
final String modifiedAt;
|
||||
final bool isFavorite;
|
||||
final String? duration;
|
||||
final String originalPath;
|
||||
final String resizePath;
|
||||
|
||||
const ImmichAsset({
|
||||
required this.id,
|
||||
required this.deviceAssetId,
|
||||
required this.userId,
|
||||
required this.deviceId,
|
||||
required this.type,
|
||||
required this.createdAt,
|
||||
required this.modifiedAt,
|
||||
required this.isFavorite,
|
||||
this.duration,
|
||||
required this.originalPath,
|
||||
required this.resizePath,
|
||||
});
|
||||
|
||||
ImmichAsset copyWith({
|
||||
String? id,
|
||||
String? deviceAssetId,
|
||||
String? userId,
|
||||
String? deviceId,
|
||||
String? type,
|
||||
String? createdAt,
|
||||
String? modifiedAt,
|
||||
bool? isFavorite,
|
||||
String? duration,
|
||||
String? originalPath,
|
||||
String? resizePath,
|
||||
}) {
|
||||
return ImmichAsset(
|
||||
id: id ?? this.id,
|
||||
deviceAssetId: deviceAssetId ?? this.deviceAssetId,
|
||||
userId: userId ?? this.userId,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
type: type ?? this.type,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
modifiedAt: modifiedAt ?? this.modifiedAt,
|
||||
isFavorite: isFavorite ?? this.isFavorite,
|
||||
duration: duration ?? this.duration,
|
||||
originalPath: originalPath ?? this.originalPath,
|
||||
resizePath: resizePath ?? this.resizePath,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final result = <String, dynamic>{};
|
||||
|
||||
result.addAll({'id': id});
|
||||
result.addAll({'deviceAssetId': deviceAssetId});
|
||||
result.addAll({'userId': userId});
|
||||
result.addAll({'deviceId': deviceId});
|
||||
result.addAll({'type': type});
|
||||
result.addAll({'createdAt': createdAt});
|
||||
result.addAll({'modifiedAt': modifiedAt});
|
||||
result.addAll({'isFavorite': isFavorite});
|
||||
if (duration != null) {
|
||||
result.addAll({'duration': duration});
|
||||
}
|
||||
result.addAll({'originalPath': originalPath});
|
||||
result.addAll({'resizePath': resizePath});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
factory ImmichAsset.fromMap(Map<String, dynamic> map) {
|
||||
return ImmichAsset(
|
||||
id: map['id'] ?? '',
|
||||
deviceAssetId: map['deviceAssetId'] ?? '',
|
||||
userId: map['userId'] ?? '',
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
type: map['type'] ?? '',
|
||||
createdAt: map['createdAt'] ?? '',
|
||||
modifiedAt: map['modifiedAt'] ?? '',
|
||||
isFavorite: map['isFavorite'] ?? false,
|
||||
duration: map['duration'],
|
||||
originalPath: map['originalPath'] ?? '',
|
||||
resizePath: map['resizePath'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ImmichAsset.fromJson(String source) =>
|
||||
ImmichAsset.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ImmichAsset(id: $id, deviceAssetId: $deviceAssetId, userId: $userId, deviceId: $deviceId, type: $type, createdAt: $createdAt, modifiedAt: $modifiedAt, isFavorite: $isFavorite, duration: $duration, originalPath: $originalPath, resizePath: $resizePath)';
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object> get props {
|
||||
return [id];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:immich_mobile/shared/models/exif.model.dart';
|
||||
|
||||
class ImmichAssetWithExif {
|
||||
final String id;
|
||||
final String deviceAssetId;
|
||||
final String userId;
|
||||
final String deviceId;
|
||||
final String type;
|
||||
final String createdAt;
|
||||
final String modifiedAt;
|
||||
final String originalPath;
|
||||
final bool isFavorite;
|
||||
final String? duration;
|
||||
final ImmichExif? exifInfo;
|
||||
|
||||
ImmichAssetWithExif({
|
||||
required this.id,
|
||||
required this.deviceAssetId,
|
||||
required this.userId,
|
||||
required this.deviceId,
|
||||
required this.type,
|
||||
required this.createdAt,
|
||||
required this.modifiedAt,
|
||||
required this.originalPath,
|
||||
required this.isFavorite,
|
||||
this.duration,
|
||||
this.exifInfo,
|
||||
});
|
||||
|
||||
ImmichAssetWithExif copyWith({
|
||||
String? id,
|
||||
String? deviceAssetId,
|
||||
String? userId,
|
||||
String? deviceId,
|
||||
String? type,
|
||||
String? createdAt,
|
||||
String? modifiedAt,
|
||||
String? originalPath,
|
||||
bool? isFavorite,
|
||||
String? duration,
|
||||
ImmichExif? exifInfo,
|
||||
}) {
|
||||
return ImmichAssetWithExif(
|
||||
id: id ?? this.id,
|
||||
deviceAssetId: deviceAssetId ?? this.deviceAssetId,
|
||||
userId: userId ?? this.userId,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
type: type ?? this.type,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
modifiedAt: modifiedAt ?? this.modifiedAt,
|
||||
originalPath: originalPath ?? this.originalPath,
|
||||
isFavorite: isFavorite ?? this.isFavorite,
|
||||
duration: duration ?? this.duration,
|
||||
exifInfo: exifInfo ?? this.exifInfo,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'deviceAssetId': deviceAssetId,
|
||||
'userId': userId,
|
||||
'deviceId': deviceId,
|
||||
'type': type,
|
||||
'createdAt': createdAt,
|
||||
'modifiedAt': modifiedAt,
|
||||
'originalPath': originalPath,
|
||||
'isFavorite': isFavorite,
|
||||
'duration': duration,
|
||||
'exifInfo': exifInfo?.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
factory ImmichAssetWithExif.fromMap(Map<String, dynamic> map) {
|
||||
return ImmichAssetWithExif(
|
||||
id: map['id'] ?? '',
|
||||
deviceAssetId: map['deviceAssetId'] ?? '',
|
||||
userId: map['userId'] ?? '',
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
type: map['type'] ?? '',
|
||||
createdAt: map['createdAt'] ?? '',
|
||||
modifiedAt: map['modifiedAt'] ?? '',
|
||||
originalPath: map['originalPath'] ?? '',
|
||||
isFavorite: map['isFavorite'] ?? false,
|
||||
duration: map['duration'],
|
||||
exifInfo:
|
||||
map['exifInfo'] != null ? ImmichExif.fromMap(map['exifInfo']) : null,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ImmichAssetWithExif.fromJson(String source) =>
|
||||
ImmichAssetWithExif.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ImmichAssetWithExif(id: $id, deviceAssetId: $deviceAssetId, userId: $userId, deviceId: $deviceId, type: $type, createdAt: $createdAt, modifiedAt: $modifiedAt, originalPath: $originalPath, isFavorite: $isFavorite, duration: $duration, exifInfo: $exifInfo)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ImmichAssetWithExif &&
|
||||
other.id == id &&
|
||||
other.deviceAssetId == deviceAssetId &&
|
||||
other.userId == userId &&
|
||||
other.deviceId == deviceId &&
|
||||
other.type == type &&
|
||||
other.createdAt == createdAt &&
|
||||
other.modifiedAt == modifiedAt &&
|
||||
other.originalPath == originalPath &&
|
||||
other.isFavorite == isFavorite &&
|
||||
other.duration == duration &&
|
||||
other.exifInfo == exifInfo;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
deviceAssetId.hashCode ^
|
||||
userId.hashCode ^
|
||||
deviceId.hashCode ^
|
||||
type.hashCode ^
|
||||
createdAt.hashCode ^
|
||||
modifiedAt.hashCode ^
|
||||
originalPath.hashCode ^
|
||||
isFavorite.hashCode ^
|
||||
duration.hashCode ^
|
||||
exifInfo.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class MapboxInfo {
|
||||
final bool isEnable;
|
||||
final String mapboxSecret;
|
||||
MapboxInfo({
|
||||
required this.isEnable,
|
||||
required this.mapboxSecret,
|
||||
});
|
||||
|
||||
MapboxInfo copyWith({
|
||||
bool? isEnable,
|
||||
String? mapboxSecret,
|
||||
}) {
|
||||
return MapboxInfo(
|
||||
isEnable: isEnable ?? this.isEnable,
|
||||
mapboxSecret: mapboxSecret ?? this.mapboxSecret,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'isEnable': isEnable,
|
||||
'mapboxSecret': mapboxSecret,
|
||||
};
|
||||
}
|
||||
|
||||
factory MapboxInfo.fromMap(Map<String, dynamic> map) {
|
||||
return MapboxInfo(
|
||||
isEnable: map['isEnable'] ?? false,
|
||||
mapboxSecret: map['mapboxSecret'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory MapboxInfo.fromJson(String source) =>
|
||||
MapboxInfo.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'MapboxInfo(isEnable: $isEnable, mapboxSecret: $mapboxSecret)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is MapboxInfo &&
|
||||
other.isEnable == isEnable &&
|
||||
other.mapboxSecret == mapboxSecret;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => isEnable.hashCode ^ mapboxSecret.hashCode;
|
||||
}
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class ServerInfo {
|
||||
final String diskSize;
|
||||
final String diskUse;
|
||||
final String diskAvailable;
|
||||
final int diskSizeRaw;
|
||||
final int diskUseRaw;
|
||||
final int diskAvailableRaw;
|
||||
final double diskUsagePercentage;
|
||||
ServerInfo({
|
||||
required this.diskSize,
|
||||
required this.diskUse,
|
||||
required this.diskAvailable,
|
||||
required this.diskSizeRaw,
|
||||
required this.diskUseRaw,
|
||||
required this.diskAvailableRaw,
|
||||
required this.diskUsagePercentage,
|
||||
});
|
||||
|
||||
ServerInfo copyWith({
|
||||
String? diskSize,
|
||||
String? diskUse,
|
||||
String? diskAvailable,
|
||||
int? diskSizeRaw,
|
||||
int? diskUseRaw,
|
||||
int? diskAvailableRaw,
|
||||
double? diskUsagePercentage,
|
||||
}) {
|
||||
return ServerInfo(
|
||||
diskSize: diskSize ?? this.diskSize,
|
||||
diskUse: diskUse ?? this.diskUse,
|
||||
diskAvailable: diskAvailable ?? this.diskAvailable,
|
||||
diskSizeRaw: diskSizeRaw ?? this.diskSizeRaw,
|
||||
diskUseRaw: diskUseRaw ?? this.diskUseRaw,
|
||||
diskAvailableRaw: diskAvailableRaw ?? this.diskAvailableRaw,
|
||||
diskUsagePercentage: diskUsagePercentage ?? this.diskUsagePercentage,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'diskSize': diskSize,
|
||||
'diskUse': diskUse,
|
||||
'diskAvailable': diskAvailable,
|
||||
'diskSizeRaw': diskSizeRaw,
|
||||
'diskUseRaw': diskUseRaw,
|
||||
'diskAvailableRaw': diskAvailableRaw,
|
||||
'diskUsagePercentage': diskUsagePercentage,
|
||||
};
|
||||
}
|
||||
|
||||
factory ServerInfo.fromMap(Map<String, dynamic> map) {
|
||||
return ServerInfo(
|
||||
diskSize: map['diskSize'] ?? '',
|
||||
diskUse: map['diskUse'] ?? '',
|
||||
diskAvailable: map['diskAvailable'] ?? '',
|
||||
diskSizeRaw: map['diskSizeRaw']?.toInt() ?? 0,
|
||||
diskUseRaw: map['diskUseRaw']?.toInt() ?? 0,
|
||||
diskAvailableRaw: map['diskAvailableRaw']?.toInt() ?? 0,
|
||||
diskUsagePercentage: map['diskUsagePercentage']?.toDouble() ?? 0.0,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ServerInfo.fromJson(String source) =>
|
||||
ServerInfo.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerInfo(diskSize: $diskSize, diskUse: $diskUse, diskAvailable: $diskAvailable, diskSizeRaw: $diskSizeRaw, diskUseRaw: $diskUseRaw, diskAvailableRaw: $diskAvailableRaw, diskUsagePercentage: $diskUsagePercentage)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ServerInfo &&
|
||||
other.diskSize == diskSize &&
|
||||
other.diskUse == diskUse &&
|
||||
other.diskAvailable == diskAvailable &&
|
||||
other.diskSizeRaw == diskSizeRaw &&
|
||||
other.diskUseRaw == diskUseRaw &&
|
||||
other.diskAvailableRaw == diskAvailableRaw &&
|
||||
other.diskUsagePercentage == diskUsagePercentage;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return diskSize.hashCode ^
|
||||
diskUse.hashCode ^
|
||||
diskAvailable.hashCode ^
|
||||
diskSizeRaw.hashCode ^
|
||||
diskUseRaw.hashCode ^
|
||||
diskAvailableRaw.hashCode ^
|
||||
diskUsagePercentage.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +1,22 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:immich_mobile/shared/models/mapbox_info.model.dart';
|
||||
import 'package:immich_mobile/shared/models/server_version.model.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
class ServerInfoState {
|
||||
final MapboxInfo mapboxInfo;
|
||||
final ServerVersion serverVersion;
|
||||
final ServerVersionReponseDto serverVersion;
|
||||
final bool isVersionMismatch;
|
||||
final String versionMismatchErrorMessage;
|
||||
|
||||
ServerInfoState({
|
||||
required this.mapboxInfo,
|
||||
required this.serverVersion,
|
||||
required this.isVersionMismatch,
|
||||
required this.versionMismatchErrorMessage,
|
||||
});
|
||||
|
||||
ServerInfoState copyWith({
|
||||
MapboxInfo? mapboxInfo,
|
||||
ServerVersion? serverVersion,
|
||||
ServerVersionReponseDto? serverVersion,
|
||||
bool? isVersionMismatch,
|
||||
String? versionMismatchErrorMessage,
|
||||
}) {
|
||||
return ServerInfoState(
|
||||
mapboxInfo: mapboxInfo ?? this.mapboxInfo,
|
||||
serverVersion: serverVersion ?? this.serverVersion,
|
||||
isVersionMismatch: isVersionMismatch ?? this.isVersionMismatch,
|
||||
versionMismatchErrorMessage:
|
||||
|
|
@ -31,32 +24,9 @@ class ServerInfoState {
|
|||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'mapboxInfo': mapboxInfo.toMap(),
|
||||
'serverVersion': serverVersion.toMap(),
|
||||
'isVersionMismatch': isVersionMismatch,
|
||||
'versionMismatchErrorMessage': versionMismatchErrorMessage,
|
||||
};
|
||||
}
|
||||
|
||||
factory ServerInfoState.fromMap(Map<String, dynamic> map) {
|
||||
return ServerInfoState(
|
||||
mapboxInfo: MapboxInfo.fromMap(map['mapboxInfo']),
|
||||
serverVersion: ServerVersion.fromMap(map['serverVersion']),
|
||||
isVersionMismatch: map['isVersionMismatch'] ?? false,
|
||||
versionMismatchErrorMessage: map['versionMismatchErrorMessage'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ServerInfoState.fromJson(String source) =>
|
||||
ServerInfoState.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerInfoState(mapboxInfo: $mapboxInfo, serverVersion: $serverVersion, isVersionMismatch: $isVersionMismatch, versionMismatchErrorMessage: $versionMismatchErrorMessage)';
|
||||
return 'ServerInfoState( serverVersion: $serverVersion, isVersionMismatch: $isVersionMismatch, versionMismatchErrorMessage: $versionMismatchErrorMessage)';
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -64,7 +34,6 @@ class ServerInfoState {
|
|||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ServerInfoState &&
|
||||
other.mapboxInfo == mapboxInfo &&
|
||||
other.serverVersion == serverVersion &&
|
||||
other.isVersionMismatch == isVersionMismatch &&
|
||||
other.versionMismatchErrorMessage == versionMismatchErrorMessage;
|
||||
|
|
@ -72,8 +41,7 @@ class ServerInfoState {
|
|||
|
||||
@override
|
||||
int get hashCode {
|
||||
return mapboxInfo.hashCode ^
|
||||
serverVersion.hashCode ^
|
||||
return serverVersion.hashCode ^
|
||||
isVersionMismatch.hashCode ^
|
||||
versionMismatchErrorMessage.hashCode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class ServerVersion {
|
||||
final int major;
|
||||
final int minor;
|
||||
final int patch;
|
||||
final int build;
|
||||
|
||||
ServerVersion({
|
||||
required this.major,
|
||||
required this.minor,
|
||||
required this.patch,
|
||||
required this.build,
|
||||
});
|
||||
|
||||
ServerVersion copyWith({
|
||||
int? major,
|
||||
int? minor,
|
||||
int? patch,
|
||||
int? build,
|
||||
}) {
|
||||
return ServerVersion(
|
||||
major: major ?? this.major,
|
||||
minor: minor ?? this.minor,
|
||||
patch: patch ?? this.patch,
|
||||
build: build ?? this.build,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'major': major,
|
||||
'minor': minor,
|
||||
'patch': patch,
|
||||
'build': build,
|
||||
};
|
||||
}
|
||||
|
||||
factory ServerVersion.fromMap(Map<String, dynamic> map) {
|
||||
return ServerVersion(
|
||||
major: map['major']?.toInt() ?? 0,
|
||||
minor: map['minor']?.toInt() ?? 0,
|
||||
patch: map['patch']?.toInt() ?? 0,
|
||||
build: map['build']?.toInt() ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ServerVersion.fromJson(String source) =>
|
||||
ServerVersion.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerVersion(major: $major, minor: $minor, patch: $patch, build: $build)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ServerVersion &&
|
||||
other.major == major &&
|
||||
other.minor == minor &&
|
||||
other.patch == patch &&
|
||||
other.build == build;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return major.hashCode ^ minor.hashCode ^ patch.hashCode ^ build.hashCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
class User {
|
||||
final String id;
|
||||
final String email;
|
||||
final String createdAt;
|
||||
final String firstName;
|
||||
final String lastName;
|
||||
|
||||
User({
|
||||
required this.id,
|
||||
required this.email,
|
||||
required this.createdAt,
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
});
|
||||
|
||||
User copyWith({
|
||||
String? id,
|
||||
String? email,
|
||||
String? createdAt,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
}) {
|
||||
return User(
|
||||
id: id ?? this.id,
|
||||
email: email ?? this.email,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
firstName: firstName ?? this.firstName,
|
||||
lastName: lastName ?? this.lastName,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
final result = <String, dynamic>{};
|
||||
|
||||
result.addAll({'id': id});
|
||||
result.addAll({'email': email});
|
||||
result.addAll({'createdAt': createdAt});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
factory User.fromMap(Map<String, dynamic> map) {
|
||||
return User(
|
||||
id: map['id'] ?? '',
|
||||
email: map['email'] ?? '',
|
||||
createdAt: map['createdAt'] ?? '',
|
||||
firstName: map['firstName'] ?? '',
|
||||
lastName: map['lastName'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory User.fromJson(String source) => User.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'UserInfo(id: $id, email: $email, createdAt: $createdAt)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is User &&
|
||||
other.id == id &&
|
||||
other.email == email &&
|
||||
other.createdAt == createdAt &&
|
||||
other.firstName == firstName &&
|
||||
other.lastName == lastName;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => id.hashCode ^ email.hashCode ^ createdAt.hashCode;
|
||||
}
|
||||
|
|
@ -1,21 +1,20 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/modules/home/models/delete_asset_response.model.dart';
|
||||
import 'package:immich_mobile/modules/home/services/asset.service.dart';
|
||||
import 'package:immich_mobile/shared/models/immich_asset.model.dart';
|
||||
import 'package:immich_mobile/shared/services/device_info.service.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
|
||||
class AssetNotifier extends StateNotifier<List<ImmichAsset>> {
|
||||
class AssetNotifier extends StateNotifier<List<AssetResponseDto>> {
|
||||
final AssetService _assetService;
|
||||
final DeviceInfoService _deviceInfoService = DeviceInfoService();
|
||||
|
||||
AssetNotifier(this._assetService) : super([]);
|
||||
|
||||
getAllAsset() async {
|
||||
List<ImmichAsset>? allAssets = await _assetService.getAllAsset();
|
||||
var allAssets = await _assetService.getAllAsset();
|
||||
|
||||
if (allAssets != null) {
|
||||
state = allAssets;
|
||||
|
|
@ -26,11 +25,11 @@ class AssetNotifier extends StateNotifier<List<ImmichAsset>> {
|
|||
state = [];
|
||||
}
|
||||
|
||||
onNewAssetUploaded(ImmichAsset newAsset) {
|
||||
onNewAssetUploaded(AssetResponseDto newAsset) {
|
||||
state = [...state, newAsset];
|
||||
}
|
||||
|
||||
deleteAssets(Set<ImmichAsset> deleteAssets) async {
|
||||
deleteAssets(Set<AssetResponseDto> deleteAssets) async {
|
||||
var deviceInfo = await _deviceInfoService.getDeviceInfo();
|
||||
var deviceId = deviceInfo["deviceId"];
|
||||
var deleteIdList = <String>[];
|
||||
|
|
@ -53,14 +52,15 @@ class AssetNotifier extends StateNotifier<List<ImmichAsset>> {
|
|||
}
|
||||
|
||||
// Delete asset on server
|
||||
List<DeleteAssetResponse>? deleteAssetResult =
|
||||
List<DeleteAssetResponseDto>? deleteAssetResult =
|
||||
await _assetService.deleteAssets(deleteAssets);
|
||||
|
||||
if (deleteAssetResult == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var asset in deleteAssetResult) {
|
||||
if (asset.status == 'success') {
|
||||
if (asset.status == DeleteAssetStatus.SUCCESS) {
|
||||
state =
|
||||
state.where((immichAsset) => immichAsset.id != asset.id).toList();
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ class AssetNotifier extends StateNotifier<List<ImmichAsset>> {
|
|||
}
|
||||
|
||||
final assetProvider =
|
||||
StateNotifierProvider<AssetNotifier, List<ImmichAsset>>((ref) {
|
||||
StateNotifierProvider<AssetNotifier, List<AssetResponseDto>>((ref) {
|
||||
return AssetNotifier(ref.watch(assetServiceProvider));
|
||||
});
|
||||
|
||||
|
|
@ -77,17 +77,25 @@ final assetGroupByDateTimeProvider = StateProvider((ref) {
|
|||
var assets = ref.watch(assetProvider);
|
||||
|
||||
assets.sortByCompare<DateTime>(
|
||||
(e) => DateTime.parse(e.createdAt), (a, b) => b.compareTo(a));
|
||||
return assets.groupListsBy((element) =>
|
||||
DateFormat('y-MM-dd').format(DateTime.parse(element.createdAt)));
|
||||
(e) => DateTime.parse(e.createdAt),
|
||||
(a, b) => b.compareTo(a),
|
||||
);
|
||||
return assets.groupListsBy(
|
||||
(element) =>
|
||||
DateFormat('y-MM-dd').format(DateTime.parse(element.createdAt)),
|
||||
);
|
||||
});
|
||||
|
||||
final assetGroupByMonthYearProvider = StateProvider((ref) {
|
||||
var assets = ref.watch(assetProvider);
|
||||
|
||||
assets.sortByCompare<DateTime>(
|
||||
(e) => DateTime.parse(e.createdAt), (a, b) => b.compareTo(a));
|
||||
(e) => DateTime.parse(e.createdAt),
|
||||
(a, b) => b.compareTo(a),
|
||||
);
|
||||
|
||||
return assets.groupListsBy((element) =>
|
||||
DateFormat('MMMM, y').format(DateTime.parse(element.createdAt)));
|
||||
return assets.groupListsBy(
|
||||
(element) =>
|
||||
DateFormat('MMMM, y').format(DateTime.parse(element.createdAt)),
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -56,4 +56,5 @@ class ReleaseInfoNotifier extends StateNotifier<String> {
|
|||
}
|
||||
|
||||
final releaseInfoProvider = StateNotifierProvider<ReleaseInfoNotifier, String>(
|
||||
(ref) => ReleaseInfoNotifier());
|
||||
(ref) => ReleaseInfoNotifier(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import 'package:immich_mobile/shared/models/mapbox_info.model.dart';
|
||||
import 'package:immich_mobile/shared/models/server_info_state.model.dart';
|
||||
import 'package:immich_mobile/shared/models/server_version.model.dart';
|
||||
import 'package:immich_mobile/shared/services/server_info.service.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class ServerInfoNotifier extends StateNotifier<ServerInfoState> {
|
||||
ServerInfoNotifier(this._serverInfoService)
|
||||
: super(
|
||||
ServerInfoState(
|
||||
mapboxInfo: MapboxInfo(isEnable: false, mapboxSecret: ""),
|
||||
serverVersion:
|
||||
ServerVersion(major: 0, patch: 0, minor: 0, build: 0),
|
||||
serverVersion: ServerVersionReponseDto(
|
||||
major: 0,
|
||||
patch_: 0,
|
||||
minor: 0,
|
||||
build: 0,
|
||||
),
|
||||
isVersionMismatch: false,
|
||||
versionMismatchErrorMessage: "",
|
||||
),
|
||||
|
|
@ -21,7 +23,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfoState> {
|
|||
final ServerInfoService _serverInfoService;
|
||||
|
||||
getServerVersion() async {
|
||||
ServerVersion? serverVersion = await _serverInfoService.getServerVersion();
|
||||
ServerVersionReponseDto? serverVersion =
|
||||
await _serverInfoService.getServerVersion();
|
||||
|
||||
if (serverVersion == null) {
|
||||
state = state.copyWith(
|
||||
|
|
@ -59,7 +62,9 @@ class ServerInfoNotifier extends StateNotifier<ServerInfoState> {
|
|||
}
|
||||
|
||||
state = state.copyWith(
|
||||
isVersionMismatch: false, versionMismatchErrorMessage: "");
|
||||
isVersionMismatch: false,
|
||||
versionMismatchErrorMessage: "",
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, int> _getDetailVersion(String version) {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import 'package:hive/hive.dart';
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/hive_box.dart';
|
||||
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
||||
import 'package:immich_mobile/shared/models/immich_asset.model.dart';
|
||||
import 'package:immich_mobile/shared/providers/asset.provider.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:socket_io_client/socket_io_client.dart';
|
||||
|
||||
class WebscoketState {
|
||||
|
|
@ -92,8 +92,11 @@ class WebsocketNotifier extends StateNotifier<WebscoketState> {
|
|||
|
||||
socket.on('on_upload_success', (data) {
|
||||
var jsonString = jsonDecode(data.toString());
|
||||
ImmichAsset newAsset = ImmichAsset.fromMap(jsonString);
|
||||
ref.watch(assetProvider.notifier).onNewAssetUploaded(newAsset);
|
||||
AssetResponseDto? newAsset = AssetResponseDto.fromJson(jsonString);
|
||||
|
||||
if (newAsset != null) {
|
||||
ref.watch(assetProvider.notifier).onNewAssetUploaded(newAsset);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
debugPrint("[WEBSOCKET] Catch Websocket Error - ${e.toString()}");
|
||||
|
|
@ -119,8 +122,11 @@ class WebsocketNotifier extends StateNotifier<WebscoketState> {
|
|||
debugPrint("[Websocket] Start listening to event on_upload_success");
|
||||
state.socket?.on('on_upload_success', (data) {
|
||||
var jsonString = jsonDecode(data.toString());
|
||||
ImmichAsset newAsset = ImmichAsset.fromMap(jsonString);
|
||||
ref.watch(assetProvider.notifier).onNewAssetUploaded(newAsset);
|
||||
AssetResponseDto? newAsset = AssetResponseDto.fromJson(jsonString);
|
||||
|
||||
if (newAsset != null) {
|
||||
ref.watch(assetProvider.notifier).onNewAssetUploaded(newAsset);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
30
mobile/lib/shared/services/api.service.dart
Normal file
30
mobile/lib/shared/services/api.service.dart
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final apiServiceProvider = Provider((ref) => ApiService());
|
||||
|
||||
class ApiService {
|
||||
late ApiClient _apiClient;
|
||||
|
||||
late UserApi userApi;
|
||||
late AuthenticationApi authenticationApi;
|
||||
late AlbumApi albumApi;
|
||||
late AssetApi assetApi;
|
||||
late ServerInfoApi serverInfoApi;
|
||||
late DeviceInfoApi deviceInfoApi;
|
||||
|
||||
setEndpoint(String endpoint) {
|
||||
_apiClient = ApiClient(basePath: endpoint);
|
||||
|
||||
userApi = UserApi(_apiClient);
|
||||
authenticationApi = AuthenticationApi(_apiClient);
|
||||
albumApi = AlbumApi(_apiClient);
|
||||
assetApi = AssetApi(_apiClient);
|
||||
serverInfoApi = ServerInfoApi(_apiClient);
|
||||
deviceInfoApi = DeviceInfoApi(_apiClient);
|
||||
}
|
||||
|
||||
setAccessToken(String accessToken) {
|
||||
_apiClient.addDefaultHeader('Authorization', 'bearer $accessToken');
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ import 'package:flutter_udid/flutter_udid.dart';
|
|||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final deviceInfoServiceProvider = Provider((_) => DeviceInfoService());
|
||||
|
||||
|
|
@ -9,12 +10,12 @@ class DeviceInfoService {
|
|||
Future<Map<String, dynamic>> getDeviceInfo() async {
|
||||
// Get device info
|
||||
var deviceId = await FlutterUdid.consistentUdid;
|
||||
var deviceType = "";
|
||||
var deviceType = DeviceTypeEnum.ANDROID;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
deviceType = "ANDROID";
|
||||
deviceType = DeviceTypeEnum.ANDROID;
|
||||
} else if (Platform.isIOS) {
|
||||
deviceType = "IOS";
|
||||
deviceType = DeviceTypeEnum.IOS;
|
||||
}
|
||||
|
||||
return {"deviceId": deviceId, "deviceType": deviceType};
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/hive_box.dart';
|
||||
|
||||
final localStorageServiceProvider = Provider((_) => LocalStorageService());
|
||||
|
||||
class LocalStorageService {
|
||||
late Box _box;
|
||||
|
||||
LocalStorageService() {
|
||||
_box = Hive.box(userInfoBox);
|
||||
}
|
||||
|
||||
T get<T>(String key) {
|
||||
return _box.get(key);
|
||||
}
|
||||
|
||||
put<T>(String key, T value) {
|
||||
return _box.put(key, value);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,10 +33,11 @@ class NetworkService {
|
|||
}
|
||||
}
|
||||
|
||||
Future<dynamic> getRequest(
|
||||
{required String url,
|
||||
bool isByteResponse = false,
|
||||
bool isStreamReponse = false}) async {
|
||||
Future<dynamic> getRequest({
|
||||
required String url,
|
||||
bool isByteResponse = false,
|
||||
bool isStreamReponse = false,
|
||||
}) async {
|
||||
try {
|
||||
var savedEndpoint = Hive.box(userInfoBox).get(serverEndpointKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/shared/models/server_info.model.dart';
|
||||
import 'package:immich_mobile/shared/models/server_version.model.dart';
|
||||
import 'package:immich_mobile/shared/services/network.service.dart';
|
||||
import 'package:immich_mobile/shared/services/api.service.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final serverInfoServiceProvider =
|
||||
Provider((ref) => ServerInfoService(ref.watch(networkServiceProvider)));
|
||||
final serverInfoServiceProvider = Provider(
|
||||
(ref) => ServerInfoService(
|
||||
ref.watch(apiServiceProvider),
|
||||
),
|
||||
);
|
||||
|
||||
class ServerInfoService {
|
||||
final NetworkService _networkService;
|
||||
ServerInfoService(this._networkService);
|
||||
final ApiService _apiService;
|
||||
ServerInfoService(this._apiService);
|
||||
|
||||
Future<ServerInfo> getServerInfo() async {
|
||||
Response response = await _networkService.getRequest(url: 'server-info');
|
||||
|
||||
return ServerInfo.fromJson(response.toString());
|
||||
Future<ServerInfoResponseDto?> getServerInfo() async {
|
||||
try {
|
||||
return await _apiService.serverInfoApi.getServerInfo();
|
||||
} catch (e) {
|
||||
debugPrint("Error [getServerInfo] ${e.toString()}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<ServerVersion?> getServerVersion() async {
|
||||
Future<ServerVersionReponseDto?> getServerVersion() async {
|
||||
try {
|
||||
Response response =
|
||||
await _networkService.getRequest(url: 'server-info/version');
|
||||
|
||||
return ServerVersion.fromJson(response.toString());
|
||||
return await _apiService.serverInfoApi.getServerVersion();
|
||||
} catch (e) {
|
||||
debugPrint("Error getting server info");
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,70 +1,49 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:immich_mobile/constants/hive_box.dart';
|
||||
import 'package:immich_mobile/shared/models/upload_profile_image_repsonse.model.dart';
|
||||
import 'package:immich_mobile/shared/models/user.model.dart';
|
||||
import 'package:immich_mobile/shared/services/network.service.dart';
|
||||
import 'package:immich_mobile/utils/dio_http_interceptor.dart';
|
||||
import 'package:immich_mobile/shared/services/api.service.dart';
|
||||
import 'package:immich_mobile/utils/files_helper.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
|
||||
final userServiceProvider =
|
||||
Provider((ref) => UserService(ref.watch(networkServiceProvider)));
|
||||
final userServiceProvider = Provider(
|
||||
(ref) => UserService(
|
||||
ref.watch(apiServiceProvider),
|
||||
),
|
||||
);
|
||||
|
||||
class UserService {
|
||||
final NetworkService _networkService;
|
||||
UserService(this._networkService);
|
||||
final ApiService _apiService;
|
||||
|
||||
Future<List<User>> getAllUsersInfo() async {
|
||||
UserService(this._apiService);
|
||||
|
||||
Future<List<UserResponseDto>?> getAllUsersInfo({required bool isAll}) async {
|
||||
try {
|
||||
var res = await _networkService.getRequest(url: 'user');
|
||||
List<dynamic> decodedData = jsonDecode(res.toString());
|
||||
List<User> result = List.from(decodedData.map((e) => User.fromMap(e)));
|
||||
|
||||
return result;
|
||||
return await _apiService.userApi.getAllUsers(isAll);
|
||||
} catch (e) {
|
||||
debugPrint("Error getAllUsersInfo ${e.toString()}");
|
||||
debugPrint("Error [getAllUsersInfo] ${e.toString()}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
Future<UploadProfileImageResponse?> uploadProfileImage(XFile image) async {
|
||||
var dio = Dio();
|
||||
dio.interceptors.add(AuthenticatedRequestInterceptor());
|
||||
String savedEndpoint = Hive.box(userInfoBox).get(serverEndpointKey);
|
||||
var mimeType = FileHelper.getMimeType(image.path);
|
||||
|
||||
final imageData = MultipartFile.fromBytes(
|
||||
await image.readAsBytes(),
|
||||
filename: image.name,
|
||||
contentType: MediaType(
|
||||
mimeType["type"],
|
||||
mimeType["subType"],
|
||||
),
|
||||
);
|
||||
|
||||
final formData = FormData.fromMap({'file': imageData});
|
||||
|
||||
Future<CreateProfileImageResponseDto?> uploadProfileImage(XFile image) async {
|
||||
try {
|
||||
Response res = await dio.post(
|
||||
'$savedEndpoint/user/profile-image',
|
||||
data: formData,
|
||||
var mimeType = FileHelper.getMimeType(image.path);
|
||||
|
||||
return await _apiService.userApi.createProfileImage(
|
||||
MultipartFile.fromBytes(
|
||||
'file',
|
||||
await image.readAsBytes(),
|
||||
filename: image.name,
|
||||
contentType: MediaType(
|
||||
mimeType["type"],
|
||||
mimeType["subType"],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
var payload = UploadProfileImageResponse.fromJson(res.toString());
|
||||
|
||||
return payload;
|
||||
} on DioError catch (e) {
|
||||
debugPrint("Error uploading file: ${e.response}");
|
||||
return null;
|
||||
} catch (e) {
|
||||
debugPrint("Error uploading file: $e");
|
||||
debugPrint("Error [uploadProfileImage] ${e.toString()}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,10 @@ class ImmichSliverPersistentAppBarDelegate
|
|||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
BuildContext context,
|
||||
double shrinkOffset,
|
||||
bool overlapsContent,
|
||||
) {
|
||||
return SizedBox.expand(child: child);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,13 @@ class SplashScreenPage extends HookConsumerWidget {
|
|||
Hive.box<HiveSavedLoginInfo>(hiveLoginInfoBox).get(savedLoginInfoKey);
|
||||
|
||||
void performLoggingIn() async {
|
||||
var isAuthenticated = await ref
|
||||
.read(authenticationProvider.notifier)
|
||||
.login(
|
||||
loginInfo!.email, loginInfo.password, loginInfo.serverUrl, true);
|
||||
var isAuthenticated =
|
||||
await ref.read(authenticationProvider.notifier).login(
|
||||
loginInfo!.email,
|
||||
loginInfo.password,
|
||||
loginInfo.serverUrl,
|
||||
true,
|
||||
);
|
||||
|
||||
if (isAuthenticated) {
|
||||
// Resume backup (if enable) then navigate
|
||||
|
|
@ -33,14 +36,17 @@ class SplashScreenPage extends HookConsumerWidget {
|
|||
}
|
||||
}
|
||||
|
||||
useEffect(() {
|
||||
if (loginInfo?.isSaveLogin == true) {
|
||||
performLoggingIn();
|
||||
} else {
|
||||
AutoRouter.of(context).push(const LoginRoute());
|
||||
}
|
||||
return null;
|
||||
}, []);
|
||||
useEffect(
|
||||
() {
|
||||
if (loginInfo?.isSaveLogin == true) {
|
||||
performLoggingIn();
|
||||
} else {
|
||||
AutoRouter.of(context).push(const LoginRoute());
|
||||
}
|
||||
return null;
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: immichBackgroundColor,
|
||||
|
|
|
|||
|
|
@ -35,23 +35,30 @@ class TabControllerPage extends ConsumerWidget {
|
|||
? null
|
||||
: BottomNavigationBar(
|
||||
selectedLabelStyle: const TextStyle(
|
||||
fontSize: 15, fontWeight: FontWeight.w600),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
unselectedLabelStyle: const TextStyle(
|
||||
fontSize: 15, fontWeight: FontWeight.w600),
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
currentIndex: tabsRouter.activeIndex,
|
||||
onTap: (index) {
|
||||
tabsRouter.setActiveIndex(index);
|
||||
},
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
label: 'tab_controller_nav_photos'.tr(),
|
||||
icon: const Icon(Icons.photo)),
|
||||
label: 'tab_controller_nav_photos'.tr(),
|
||||
icon: const Icon(Icons.photo),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'tab_controller_nav_search'.tr(),
|
||||
icon: const Icon(Icons.search)),
|
||||
label: 'tab_controller_nav_search'.tr(),
|
||||
icon: const Icon(Icons.search),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'tab_controller_nav_sharing'.tr(),
|
||||
icon: const Icon(Icons.group_outlined)),
|
||||
label: 'tab_controller_nav_sharing'.tr(),
|
||||
icon: const Icon(Icons.group_outlined),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -54,13 +54,16 @@ class VersionAnnouncementOverlay extends HookConsumerWidget {
|
|||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: 'WorkSans',
|
||||
color: Colors.black87,
|
||||
height: 1.2),
|
||||
fontSize: 14,
|
||||
fontFamily: 'WorkSans',
|
||||
color: Colors.black87,
|
||||
height: 1.2,
|
||||
),
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: 'version_announcement_overlay_text_1'.tr(),
|
||||
text:
|
||||
'version_announcement_overlay_text_1'
|
||||
.tr(),
|
||||
),
|
||||
const TextSpan(
|
||||
text: ' Immich ',
|
||||
|
|
@ -71,11 +74,14 @@ class VersionAnnouncementOverlay extends HookConsumerWidget {
|
|||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: "version_announcement_overlay_text_2".tr(),
|
||||
text:
|
||||
"version_announcement_overlay_text_2"
|
||||
.tr(),
|
||||
),
|
||||
TextSpan(
|
||||
text: "version_announcement_overlay_release_notes"
|
||||
.tr(),
|
||||
text:
|
||||
"version_announcement_overlay_release_notes"
|
||||
.tr(),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
|
|
@ -83,7 +89,9 @@ class VersionAnnouncementOverlay extends HookConsumerWidget {
|
|||
..onTap = goToReleaseNote,
|
||||
),
|
||||
TextSpan(
|
||||
text: "version_announcement_overlay_text_3".tr(),
|
||||
text:
|
||||
"version_announcement_overlay_text_3"
|
||||
.tr(),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
@ -92,22 +100,25 @@ class VersionAnnouncementOverlay extends HookConsumerWidget {
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
visualDensity: VisualDensity.standard,
|
||||
primary: Colors.indigo,
|
||||
onPrimary: Colors.grey[50],
|
||||
elevation: 2,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10, horizontal: 25),
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
visualDensity: VisualDensity.standard,
|
||||
primary: Colors.indigo,
|
||||
onPrimary: Colors.grey[50],
|
||||
elevation: 2,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 25,
|
||||
),
|
||||
onPressed: onAcknowledgeTapped,
|
||||
child: const Text(
|
||||
"version_announcement_overlay_ack",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
).tr()),
|
||||
),
|
||||
onPressed: onAcknowledgeTapped,
|
||||
child: const Text(
|
||||
"version_announcement_overlay_ack",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
).tr(),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue