Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* 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
Gorniv committed May 9, 2020
2 parents 3d36a96 + a54f596 commit 5da759c
Show file tree
Hide file tree
Showing 61 changed files with 2,630 additions and 289 deletions.
4 changes: 0 additions & 4 deletions .flutter-plugins

This file was deleted.

93 changes: 78 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,82 @@ pubspec.lock
# If you don't generate documentation locally you can remove this line.
doc/api/

# Avoid committing generated Javascript files:
*.dart.js
*.info.json # Produced by the --dump-info flag.
*.js # When generated by dart2js. Don't specify *.js if your
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map
.idea/iXn.iml
.idea/modules.xml
.idea/vcs.xml
.idea/workspace.xml
.idea/libraries/Dart_Packages.xml
.idea/libraries/Dart_SDK.xml
.idea/libraries/Flutter_Plugins.xml
.flutter-plugins-dependencies

# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
# .vscode/

# Flutter/Dart/Pub related
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
Runner.ipa
Runner.app.dSYM.zip
report.xml
android/app/release
android/app/src/debug
.flutter-plugins-dependencies
flutter_export_environment.sh
11 changes: 8 additions & 3 deletions lib/app/app_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:doppio_dev_ixn/home/index.dart';
import 'package:doppio_dev_ixn/project/index.dart';
import 'package:doppio_dev_ixn/project_setting/index.dart';
import 'package:doppio_dev_ixn/projects/index.dart';
import 'package:doppio_dev_ixn/service/context_service.dart';
import 'package:doppio_dev_ixn/service/translate_service.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -56,6 +58,7 @@ class _AppPageState extends State<AppPage> with WidgetsBindingObserver {
// fontFamily: 'OpenSans'
);
return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: navigatorKey,
key: const Key('MaterialApp'),
localizationsDelegates: <LocalizationsDelegate<dynamic>>[
Expand All @@ -72,7 +75,7 @@ class _AppPageState extends State<AppPage> with WidgetsBindingObserver {
builder: (contextHome, snapshot) {
ContextService().buidlContext(contextHome);
TranslateService().update(contextHome);
return HomePage();
return ProjectsPage();
}),
routes: _routes(),
);
Expand All @@ -83,7 +86,9 @@ class _AppPageState extends State<AppPage> with WidgetsBindingObserver {
Map<String, WidgetBuilder> _routes() {
return <String, WidgetBuilder>{
'': (BuildContext context) => AppPage(),
HomePage.routeName: (BuildContext context) => HomePage(),
ProjectsPage.routeName: (BuildContext context) => ProjectsPage(),
ProjectPage.routeName: (BuildContext context) => ProjectPage(),
ProjectSettingPage.routeName: (BuildContext context) => ProjectSettingPage(),
};
}

Expand Down
4 changes: 4 additions & 0 deletions lib/core/ext.dart
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;
}
140 changes: 140 additions & 0 deletions lib/core/hive_cache_manager.dart
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();
}
}
}
4 changes: 4 additions & 0 deletions lib/core/index.dart
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';
4 changes: 4 additions & 0 deletions lib/generated/intl/messages_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ import 'package:intl/message_lookup_by_library.dart';
import 'package:intl/src/intl_helpers.dart';

import 'messages_en.dart' as messages_en;
import 'messages_ko_KR.dart' as messages_ko_kr;
import 'messages_ru_RU.dart' as messages_ru_ru;

typedef Future<dynamic> LibraryLoader();
Map<String, LibraryLoader> _deferredLibraries = {
'en': () => new Future.value(null),
'ko_KR': () => new Future.value(null),
'ru_RU': () => new Future.value(null),
};

MessageLookupByLibrary _findExact(String localeName) {
switch (localeName) {
case 'en':
return messages_en.messages;
case 'ko_KR':
return messages_ko_kr.messages;
case 'ru_RU':
return messages_ru_ru.messages;
default:
Expand Down
21 changes: 20 additions & 1 deletion lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';

static m0(locale, path) =>
"Locale ${locale} from file ${path} doesnt supported. Use name of file like \'intl_ko_KR.arb\' or \'ko-KR.json\' where \'ko\' - target locale";

final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{"error_reload": MessageLookupByLibrary.simpleMessage("Reload")};
static _notInlinedMessages(_) => <String, Function>{
"close": MessageLookupByLibrary.simpleMessage("Close"),
"discard": MessageLookupByLibrary.simpleMessage("Discard"),
"error_locale_dublicate": MessageLookupByLibrary.simpleMessage("dublicate locale"),
"error_locale_notsupport": m0,
"error_reload": MessageLookupByLibrary.simpleMessage("Reload"),
"error_unsaved": MessageLookupByLibrary.simpleMessage("The form contains some unsaved changes.\r\nDo you want to save all entered data?"),
"page_settings": MessageLookupByLibrary.simpleMessage("Project Settings"),
"project_default_locale": MessageLookupByLibrary.simpleMessage("Default Locale"),
"project_key": MessageLookupByLibrary.simpleMessage("Key"),
"project_name": MessageLookupByLibrary.simpleMessage("Project Name"),
"projects_card_locale": MessageLookupByLibrary.simpleMessage("Locale"),
"projects_card_locales": MessageLookupByLibrary.simpleMessage("Supported Locales"),
"projects_card_name": MessageLookupByLibrary.simpleMessage("Name"),
"save": MessageLookupByLibrary.simpleMessage("Save"),
"save_data": MessageLookupByLibrary.simpleMessage("Save changes")
};
}
24 changes: 24 additions & 0 deletions lib/generated/intl/messages_ko_KR.dart
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>{};
}
15 changes: 14 additions & 1 deletion lib/generated/intl/messages_ru_RU.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,18 @@ class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'ru_RU';

final messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function>{"error_reload": MessageLookupByLibrary.simpleMessage("Перегрузить")};
static _notInlinedMessages(_) => <String, Function>{
"discard": MessageLookupByLibrary.simpleMessage("Отклонить"),
"error_reload": MessageLookupByLibrary.simpleMessage("Переезагрузить"),
"error_unsaved": MessageLookupByLibrary.simpleMessage("Форма содержит неесохраненные данные, сохрать данные?"),
"page_settings": MessageLookupByLibrary.simpleMessage("Настройки проекта"),
"project_default_locale": MessageLookupByLibrary.simpleMessage("Локализация по умолчанию"),
"project_key": MessageLookupByLibrary.simpleMessage("Ключ"),
"project_name": MessageLookupByLibrary.simpleMessage("Название проекта"),
"projects_card_locale": MessageLookupByLibrary.simpleMessage("Локализация"),
"projects_card_locales": MessageLookupByLibrary.simpleMessage("Локализаций"),
"projects_card_name": MessageLookupByLibrary.simpleMessage("Название"),
"save": MessageLookupByLibrary.simpleMessage("Сохранить"),
"save_data": MessageLookupByLibrary.simpleMessage("Сохранить изменения")
};
}
Loading

0 comments on commit 5da759c

Please sign in to comment.