-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: fix: map feat: use import from files feat: more actions for project feat: use file_access feat: can pop in settings feat: improve editor feat: settings page update translator feat: update editor feat: start do project settings, main screen update ignore feat: add projects
- Loading branch information
Showing
61 changed files
with
2,630 additions
and
289 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extension Linq<T> on List<T> { | ||
/// default = null | ||
T get firstOrDefault => isEmpty ? null : first; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import 'package:doppio_dev_ixn/core/logger.dart'; | ||
|
||
import 'package:hive/hive.dart'; | ||
import 'package:semaphore/semaphore.dart'; | ||
import 'package:pedantic/pedantic.dart'; | ||
|
||
class HiveCacheManager { | ||
String _key = 'cache_v1'; | ||
String _nameLogger = 'HiveCacheManager'; | ||
String _keyTime = 'cache_time_v1'; | ||
Duration duration = Duration(hours: 8); | ||
final _sm = LocalSemaphore(1); | ||
|
||
static HiveCacheManager _instance; | ||
Stream<dynamic> _compactStream; | ||
LazyBox<dynamic> _box; | ||
Box<dynamic> _boxTime; | ||
|
||
factory HiveCacheManager() { | ||
_instance ??= HiveCacheManager.internal(); | ||
return _instance; | ||
} | ||
|
||
void init(String name, Duration duration) { | ||
_key = '${name.toLowerCase()}_cache_v1'; | ||
_nameLogger = '${name}CacheManager'; | ||
_keyTime = '${name.toLowerCase()}_time_cache_v1'; | ||
this.duration = duration; | ||
} | ||
|
||
Future<void> openAsync() async { | ||
final path = _key; | ||
final pathTime = _keyTime; | ||
_box = await Hive.openLazyBox(_key, path: path); | ||
_boxTime = await Hive.openBox(_keyTime, path: pathTime); | ||
_compactStream = Stream<void>.periodic(const Duration(seconds: 311)); | ||
unawaited(_compactStream.forEach((_) async { | ||
await _box.compact(); | ||
await _boxTime.compact(); | ||
})); | ||
} | ||
|
||
HiveCacheManager.internal(); | ||
|
||
bool containsKey(String itemId, {bool useExpire = true}) { | ||
try { | ||
_sm.acquire(); | ||
if (useExpire == true && duration != null) { | ||
if (!_boxTime.containsKey(itemId)) { | ||
return false; | ||
} | ||
final time = _boxTime.get(itemId) as DateTime; | ||
final difference = time.difference(DateTime.now()); | ||
if (difference > duration) { | ||
_boxTime.delete(itemId); | ||
return false; | ||
} | ||
} | ||
if (!_box.containsKey(itemId)) { | ||
return false; | ||
} | ||
return true; | ||
} catch (error, stackTrace) { | ||
log('$error', name: _nameLogger, error: error, stackTrace: stackTrace); | ||
return false; | ||
} finally { | ||
_sm.release(); | ||
} | ||
} | ||
|
||
/// offsetExpire - less time save (if add time) | ||
Future<void> putAsync(String key, dynamic value, {Duration offsetExpire, bool useExpire = true}) async { | ||
try { | ||
await _sm.acquire(); | ||
if (useExpire == true && duration != null) { | ||
var time = DateTime.now(); | ||
if (offsetExpire != null) { | ||
time.add(offsetExpire); | ||
} | ||
await _boxTime.put(key, time); | ||
} | ||
await _box.put(key, value); | ||
} finally { | ||
_sm.release(); | ||
} | ||
} | ||
|
||
Future<dynamic> getItemAsync(String keyId, {bool useExpire = true}) async { | ||
try { | ||
await _sm.acquire(); | ||
return await (_getItemAsync(keyId, useExpire: useExpire)); | ||
} finally { | ||
_sm.release(); | ||
} | ||
} | ||
|
||
Future<dynamic> _getItemAsync(String keyId, {bool useExpire = true}) async { | ||
try { | ||
if (useExpire == true) { | ||
if (containsKey(keyId, useExpire: useExpire) == false) return null; | ||
} | ||
return await _box.get(keyId); | ||
} finally {} | ||
} | ||
|
||
Future<List<dynamic>> getAllAsync({bool useExpire = true}) async { | ||
try { | ||
await _sm.acquire(); | ||
final keys = _box.keys.toList(); | ||
final result = []; | ||
for (var item in keys) { | ||
final map = await _getItemAsync(item.toString(), useExpire: useExpire); | ||
result.add(map); | ||
} | ||
return result; | ||
} finally { | ||
_sm.release(); | ||
} | ||
} | ||
|
||
Future<void> deleteAsync(String keyCurrent) async { | ||
try { | ||
await _sm.acquire(); | ||
await _box.delete(keyCurrent); | ||
await _boxTime.delete(keyCurrent); | ||
} finally { | ||
_sm.release(); | ||
} | ||
} | ||
|
||
Future<void> compactAsync() async { | ||
try { | ||
await _sm.acquire(); | ||
await _box.compact(); | ||
await _boxTime.compact(); | ||
} finally { | ||
_sm.release(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export 'ext.dart'; | ||
export 'hive_cache_manager.dart'; | ||
export 'logger.dart'; | ||
export 'simple_bloc_delegate.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart | ||
// This is a library that provides messages for a ko_KR locale. All the | ||
// messages from the main program should be duplicated here with the same | ||
// function name. | ||
|
||
// Ignore issues from commonly used lints in this file. | ||
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new | ||
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering | ||
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases | ||
// ignore_for_file:unused_import, file_names | ||
|
||
import 'package:intl/intl.dart'; | ||
import 'package:intl/message_lookup_by_library.dart'; | ||
|
||
final messages = new MessageLookup(); | ||
|
||
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); | ||
|
||
class MessageLookup extends MessageLookupByLibrary { | ||
String get localeName => 'ko_KR'; | ||
|
||
final messages = _notInlinedMessages(_notInlinedMessages); | ||
static _notInlinedMessages(_) => <String, Function>{}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.