Initial draft
This commit is contained in:
21
lib/repository/config.dart
Normal file
21
lib/repository/config.dart
Normal file
@ -0,0 +1,21 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:hl_lieferservice/services/erpframe.dart';
|
||||
import 'package:hl_lieferservice/persistence.dart';
|
||||
import 'package:hl_lieferservice/repository.dart';
|
||||
|
||||
/// This repository manages the configuration file stored on the phone
|
||||
/// locally.
|
||||
class ConfigurationRepository extends BaseRepository{
|
||||
const ConfigurationRepository({required super.path});
|
||||
|
||||
Future<LocalDocuFrameConfiguration> getDocuFrameConfiguration() async {
|
||||
String content = await FileStorage().read(path);
|
||||
return LocalDocuFrameConfiguration.fromJson(json.decode(content));
|
||||
}
|
||||
|
||||
Future<void> setDocuFrameConfiguration(LocalDocuFrameConfiguration configuration) async {
|
||||
String content = json.encode(configuration.toJson());
|
||||
await FileStorage().write(path, content);
|
||||
}
|
||||
}
|
||||
38
lib/repository/file.dart
Normal file
38
lib/repository/file.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class FileRepository {
|
||||
const FileRepository({required this.baseDirectory});
|
||||
final Directory baseDirectory;
|
||||
|
||||
Future<File> persistTemporaryFile(XFile file, String name) async {
|
||||
File fileOnDisk = File("${baseDirectory.path}/$name");
|
||||
await fileOnDisk.writeAsBytes(await file.readAsBytes());
|
||||
|
||||
return fileOnDisk;
|
||||
}
|
||||
|
||||
Future<File> persistTemporaryFileFromBytes(Uint8List bytes, String name) async {
|
||||
File fileOnDisk = File("${baseDirectory.path}/$name");
|
||||
await fileOnDisk.writeAsBytes(bytes as List<int>);
|
||||
|
||||
return fileOnDisk;
|
||||
}
|
||||
|
||||
Future<List<File>> getFilesByPrefix(String prefix) async {
|
||||
return await baseDirectory
|
||||
.list()
|
||||
.where((file) => file is File)
|
||||
.map((file) => file as File)
|
||||
.where((file) => file.path.split("/").last.startsWith(prefix))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<void> deleteAllFilesByPrefix(String prefix) async {
|
||||
for (File file in await getFilesByPrefix(prefix)) {
|
||||
await file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
lib/repository/note.dart
Normal file
28
lib/repository/note.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:hl_lieferservice/model/delivery.dart';
|
||||
import 'package:hl_lieferservice/feature/delivery/detail/service/notes_service.dart';
|
||||
|
||||
class NoteRepository {
|
||||
final NoteService service;
|
||||
NoteRepository({required this.service});
|
||||
|
||||
Future<Note> addNote(String deliveryId, String content) async {
|
||||
return service.addNote(content, int.parse(deliveryId));
|
||||
}
|
||||
|
||||
Future<void> deleteNote(String noteId) async {
|
||||
return service.deleteNote(int.parse(noteId));
|
||||
}
|
||||
|
||||
Future<List<Note>> loadNotes(String deliveryId) async {
|
||||
return [];
|
||||
}
|
||||
|
||||
Future<List<Uint8List>> loadImages(String deliveryId) async {
|
||||
return [];
|
||||
}
|
||||
|
||||
Future<void> addImage(String deliveryId, Uint8List imageBytes) async {}
|
||||
Future<void> deleteImage(String deliveryId, String imageIdentifier) async {}
|
||||
}
|
||||
3
lib/repository/user_repository.dart
Normal file
3
lib/repository/user_repository.dart
Normal file
@ -0,0 +1,3 @@
|
||||
class UserRepository {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user