2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-03-01 21:52:13 +00:00
|
|
|
import 'package:stackwallet/db/hive/db.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class TradeNotesService extends ChangeNotifier {
|
|
|
|
Map<String, String> get all {
|
|
|
|
final Map<String, String> _all = {};
|
|
|
|
for (final key in DB.instance.keys<String>(boxName: DB.boxNameTradeNotes)) {
|
|
|
|
if (key is String) {
|
|
|
|
_all[key] =
|
|
|
|
DB.instance.get<String>(boxName: DB.boxNameTradeNotes, key: key) ??
|
|
|
|
"";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _all;
|
|
|
|
}
|
|
|
|
|
|
|
|
String getNote({required String tradeId}) {
|
|
|
|
return DB.instance
|
|
|
|
.get<String>(boxName: DB.boxNameTradeNotes, key: tradeId) ??
|
|
|
|
"";
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> set({
|
|
|
|
required String tradeId,
|
|
|
|
required String note,
|
|
|
|
}) async {
|
|
|
|
await DB.instance
|
|
|
|
.put<String>(boxName: DB.boxNameTradeNotes, key: tradeId, value: note);
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> delete({
|
|
|
|
required String tradeId,
|
|
|
|
}) async {
|
|
|
|
await DB.instance
|
|
|
|
.delete<String>(boxName: DB.boxNameTradeNotes, key: tradeId);
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|