Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  update readme
  feat: check update
  update readme
  update readme
  • Loading branch information
Gorniv committed May 12, 2020
2 parents d96436f + 8543e98 commit b775d8c
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 8 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Control your localization of apps with iXn!

please support me:

- star my repo and use app
- install [meows.app](https://meows.app) - player for Apple Music (use flutter)
- install extension for BLoC - [[FF] Flutter Files](https://marketplace.visualstudio.com/items?itemName=gornivv.vscode-flutter-files)
- use flutter - flutter the best!

## it-challenge

Create it product every day! - https://medium.com/it-challenge

## Is it ideal code?

No, this a product for users who want control localization of apps.
Expand All @@ -16,6 +27,7 @@ No, this a product for users who want control localization of apps.
- export to json.arb, custom format(json)
- UI for edit words
- web and mac version
- check update version

[ ] compare origin and import

Expand All @@ -37,6 +49,8 @@ No, this a product for users who want control localization of apps.

[ ] app settings(locale & theme)

[ ] use DI (kiwi)

Screens:

![projects](Screenshots/main.png)
Expand Down
2 changes: 1 addition & 1 deletion _bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ else
fi
echo 'version: '$newversion
sed -i '' 's|version: .*|version: '$newversion'|' pubspec.yaml
# sed -i '' 's|appVersion = .*|appVersion = \"'$newversion'\";|g' lib/main.dart
sed -i '' 's|appVersion = .*|appVersion = \"'$newversion'\";|g' lib/main.dart
echo 'bumped version'
17 changes: 17 additions & 0 deletions lib/app/app_event.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'dart:async';
import 'dart:developer' as developer;

import 'package:doppio_dev_ixn/main.dart';
import 'package:doppio_dev_ixn/service/index.dart';
import 'package:flutter/widgets.dart';
import 'package:doppio_dev_ixn/app/index.dart';
import 'package:meta/meta.dart';
import 'package:pedantic/pedantic.dart';
import 'package:http/http.dart' as http;

@immutable
abstract class AppEvent {
Expand All @@ -22,12 +26,25 @@ class LoadAppEvent extends AppEvent {
Stream<AppState> applyAsync({AppState currentState, AppBloc bloc}) async* {
try {
yield UnAppState();
unawaited(checkUpdate());
yield InAppState(0);
} catch (_, stackTrace) {
developer.log('$_', name: 'LoadAppEvent', error: _, stackTrace: stackTrace);
yield ErrorAppState(errorMessage: _?.toString());
}
}

Future checkUpdate() async {
final response = await http.get('https://github.com/doppio-dev/iXn/tags');
if (response.statusCode == 200) {
final exp = RegExp(r'(v_\d+\.\d+\.\d+\+\(\d+\))');
final lastReleaseMatch = exp?.firstMatch(response.body);
final lastRelease = lastReleaseMatch?.group(0)?.replaceAll('(', '')?.replaceAll(')', '');
if (lastRelease?.substring(2) != appVersion) {
NotificationService.showUpdate();
}
}
}
}

class ChangeThemeAppEvent extends AppEvent {
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_en_US.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class MessageLookup extends MessageLookupByLibrary {
"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?"),
"notif_need_update": MessageLookupByLibrary.simpleMessage("Please, update to last version fo the app"),
"notif_ok": MessageLookupByLibrary.simpleMessage("Ok"),
"notif_update": MessageLookupByLibrary.simpleMessage("Update"),
"page_settings": MessageLookupByLibrary.simpleMessage("Project Settings"),
"project_add": MessageLookupByLibrary.simpleMessage("Add"),
"project_default_locale": MessageLookupByLibrary.simpleMessage("Default Locale"),
Expand Down
18 changes: 18 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/l10n/intl_en_US.arb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"projects_emprty": "Please, add new project for control Localizations of your apps",
"projects_remove": "Remove",
"notif_ok": "Ok",
"notif_update": "Update",
"notif_need_update" : "Please, update to last version fo the app",
"edit_lang_approve": "Approve after import or change",
"edit_lang_changed": "Value of default locale was changed",
"value_required": "value required",
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:doppio_dev_ixn/core/simple_bloc_delegate.dart';
import 'project/index.dart';

GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(debugLabel: 'mainApp');
String appVersion;

Future<void> main() async {
await init();
Expand All @@ -28,6 +29,7 @@ Future<void> init({bool ensureInitialized = true}) async {
BlocSupervisor.delegate = SimpleBlocDelegate();
await ProjectsCacheManager().openAsync();
await AutoTranslateCacheManager().openAsync();
appVersion = '0.1.0+1';
} catch (error, stackTrace) {
log('$error', name: 'Main', error: '$error', stackTrace: stackTrace);
}
Expand Down
43 changes: 38 additions & 5 deletions lib/service/notification_service.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:doppio_dev_ixn/service/index.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class NotificationService {
static void showError(String error) {
BotToast.showNotification(duration: Duration(seconds: 7), onTap: () {}, title: (_) => Text(error));
}

static void showQuestion(String message, Function onDone) {
// BotToast.showNotification(
// duration: Duration(seconds: 4),
// onTap: () {},
// title: (_) => Text(message),
// );
BotToast.showCustomNotification(
duration: Duration(seconds: 10),
onlyOne: true,
Expand Down Expand Up @@ -45,4 +41,41 @@ class NotificationService {
),
);
}

static void showUpdate() {
BotToast.showCustomNotification(
duration: Duration(seconds: 10),
onlyOne: true,
toastBuilder: (cancelFunc) => GestureDetector(
onTap: () {
cancelFunc();
},
child: Card(
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(TranslateService().locale.notif_need_update),
),
Spacer(),
Padding(
padding: const EdgeInsets.all(8.0),
child: RaisedButton(
onPressed: () async {
cancelFunc();
final url = 'https://github.com/doppio-dev/iXn/releases';
if (await canLaunch(url)) {
await launch(url);
}
},
child: Text(TranslateService().locale.notif_update),
),
),
],
),
),
),
);
}
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.5.0+1
version: 0.5.0+8

environment:
sdk: ">=2.7.0 <3.0.0"
Expand All @@ -34,7 +34,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: 0.1.3
url_launcher: 5.4.5
url_launcher: 5.4.7
url_launcher_macos: 0.0.1+5
url_launcher_web: 0.1.1+2
semaphore: 0.1.4
Expand Down

0 comments on commit b775d8c

Please sign in to comment.