agent-flutter 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-flutter",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Portable Flutter skill/rule pack initializer for multiple AI IDEs.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -290,6 +290,7 @@ JSON
290
290
  run_fvm flutter pub add get flutter_bloc equatable dio retrofit json_annotation flutter_dotenv flutter_svg intl
291
291
  run_fvm flutter pub add flutter_keyboard_visibility:^6.0.0 cached_network_image:^3.3.1 flutter_inappwebview:^6.1.5 pin_code_fields:^8.0.1 gif:^2.3.0
292
292
  run_fvm flutter pub add carousel_slider:^5.1.1 smooth_page_indicator:^2.0.1
293
+ run_fvm flutter pub add shared_preferences
293
294
  run_fvm flutter pub add common_widget --git-url https://github.com/tuan-urani/common_widget --git-ref main
294
295
  run_fvm flutter pub add --dev build_runner retrofit_generator json_serializable
295
296
 
@@ -305,9 +306,11 @@ mkdir -p \
305
306
  lib/src/helper \
306
307
  lib/src/locale \
307
308
  lib/src/ui/base \
309
+ lib/src/ui/base/interactor \
308
310
  lib/src/ui/main \
309
311
  lib/src/ui/home/binding \
310
312
  lib/src/ui/home/bloc \
313
+ lib/src/ui/splash \
311
314
  lib/src/ui/routing \
312
315
  lib/src/ui/widgets \
313
316
  lib/src/utils
@@ -333,7 +336,7 @@ class App extends StatelessWidget {
333
336
  Widget build(BuildContext context) {
334
337
  return GetMaterialApp(
335
338
  debugShowCheckedModeBanner: false,
336
- initialRoute: AppPages.main,
339
+ initialRoute: AppPages.splash,
337
340
  getPages: AppPages.pages,
338
341
  translations: TranslationManager(),
339
342
  locale: TranslationManager.defaultLocale,
@@ -850,20 +853,84 @@ extension DouleWithoutDecimal on double? {
850
853
  }
851
854
  EOF
852
855
 
856
+ cat >lib/src/ui/base/interactor/page_states.dart <<'EOF'
857
+ enum PageState { initial, loading, failure, success }
858
+ EOF
859
+
860
+ cat >lib/src/utils/app_shared.dart <<'EOF'
861
+ import 'dart:async';
862
+
863
+ import 'package:shared_preferences/shared_preferences.dart';
864
+
865
+ class AppShared {
866
+ static const String keyName = 'app';
867
+ static const String keyBox = '${keyName}_shared';
868
+
869
+ static const String _keyFcmToken = '${keyName}_keyFCMToken';
870
+ static const String _keyTokenValue = '${keyName}_keyTokenValue';
871
+ static const String _keyLanguageCode = '${keyName}_keyLanguageCode';
872
+
873
+ final SharedPreferences _prefs;
874
+ final StreamController<String?> _tokenValueController =
875
+ StreamController<String?>.broadcast();
876
+
877
+ AppShared(this._prefs);
878
+
879
+ Future<void> setTokenFcm(String firebaseToken) async {
880
+ await _prefs.setString(_keyFcmToken, firebaseToken);
881
+ }
882
+
883
+ String? getTokenFcm() => _prefs.getString(_keyFcmToken);
884
+
885
+ Future<void> setLanguageCode(String languageCode) async {
886
+ await _prefs.setString(_keyLanguageCode, languageCode);
887
+ }
888
+
889
+ String? getLanguageCode() => _prefs.getString(_keyLanguageCode);
890
+
891
+ Future<void> setTokenValue(String tokenValue) async {
892
+ await _prefs.setString(_keyTokenValue, tokenValue);
893
+ _tokenValueController.add(tokenValue);
894
+ }
895
+
896
+ String? getTokenValue() => _prefs.getString(_keyTokenValue);
897
+
898
+ Stream<String?> watchTokenValue() => _tokenValueController.stream;
899
+
900
+ Future<int> clear() async {
901
+ await _prefs.remove(_keyFcmToken);
902
+ await _prefs.remove(_keyTokenValue);
903
+ await _prefs.remove(_keyLanguageCode);
904
+ _tokenValueController.add(null);
905
+ return 1;
906
+ }
907
+
908
+ void dispose() {
909
+ _tokenValueController.close();
910
+ }
911
+ }
912
+ EOF
913
+
853
914
  cat >lib/src/utils/app_pages.dart <<EOF
854
915
  import 'package:get/get.dart';
855
916
 
856
917
  import 'package:$APP_PACKAGE_NAME/src/ui/home/binding/home_binding.dart';
857
918
  import 'package:$APP_PACKAGE_NAME/src/ui/home/home_page.dart';
858
919
  import 'package:$APP_PACKAGE_NAME/src/ui/main/main_page.dart';
920
+ import 'package:$APP_PACKAGE_NAME/src/ui/splash/splash_page.dart';
859
921
 
860
922
  class AppPages {
861
923
  AppPages._();
862
924
 
925
+ static const String splash = '/splash';
863
926
  static const String main = '/';
864
927
  static const String home = '/home';
865
928
 
866
929
  static final List<GetPage<dynamic>> pages = <GetPage<dynamic>>[
930
+ GetPage(
931
+ name: splash,
932
+ page: () => const SplashPage(),
933
+ ),
867
934
  GetPage(
868
935
  name: main,
869
936
  page: () => const MainPage(),
@@ -878,11 +945,47 @@ class AppPages {
878
945
  }
879
946
  EOF
880
947
 
948
+ cat >lib/src/ui/splash/splash_page.dart <<EOF
949
+ import 'package:flutter/material.dart';
950
+ import 'package:get/get.dart';
951
+
952
+ import 'package:$APP_PACKAGE_NAME/src/utils/app_pages.dart';
953
+
954
+ class SplashPage extends StatefulWidget {
955
+ const SplashPage({super.key});
956
+
957
+ @override
958
+ State<SplashPage> createState() => _SplashPageState();
959
+ }
960
+
961
+ class _SplashPageState extends State<SplashPage> {
962
+ @override
963
+ void initState() {
964
+ super.initState();
965
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
966
+ await Future<void>.delayed(const Duration(seconds: 2));
967
+ if (!mounted) return;
968
+ Get.offNamed(AppPages.main);
969
+ });
970
+ }
971
+
972
+ @override
973
+ Widget build(BuildContext context) {
974
+ return const Scaffold(
975
+ body: Center(
976
+ child: CircularProgressIndicator(),
977
+ ),
978
+ );
979
+ }
980
+ }
981
+ EOF
982
+
881
983
  cat >lib/src/locale/locale_key.dart <<'EOF'
882
984
  class LocaleKey {
883
985
  LocaleKey._();
884
986
 
885
987
  static const String homeTitle = 'home_title';
988
+ static const String loginSessionExpires = 'loginSessionExpires';
886
989
  static const String widgetCancel = 'widgetCancel';
887
990
  static const String widgetConfirm = 'widgetConfirm';
888
991
  }
@@ -893,6 +996,7 @@ import 'locale_key.dart';
893
996
 
894
997
  final Map<String, String> enUs = <String, String>{
895
998
  LocaleKey.homeTitle: 'Home',
999
+ LocaleKey.loginSessionExpires: 'Login session expires!',
896
1000
  LocaleKey.widgetCancel: 'Cancel',
897
1001
  LocaleKey.widgetConfirm: 'Confirm',
898
1002
  };
@@ -903,6 +1007,7 @@ import 'locale_key.dart';
903
1007
 
904
1008
  final Map<String, String> jaJp = <String, String>{
905
1009
  LocaleKey.homeTitle: 'ホーム',
1010
+ LocaleKey.loginSessionExpires: 'ログインセッションが期限切れです!',
906
1011
  LocaleKey.widgetCancel: 'キャンセル',
907
1012
  LocaleKey.widgetConfirm: '決定する',
908
1013
  };