From a9a79c192a5363fba660221c29b5371fe907777b Mon Sep 17 00:00:00 2001 From: hemengyang Date: Thu, 16 Jul 2020 21:17:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=20(#48)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 符合 BLoC 的命名规则 * 重新生成项目 * 完善认证 --- .gitignore | 7 +++ .metadata | 4 +- CHANGELOG.md | 9 ++- android/app/src/debug/AndroidManifest.xml | 2 +- android/app/src/main/AndroidManifest.xml | 2 +- .../{home => smart_home}/MainActivity.kt | 2 +- android/app/src/profile/AndroidManifest.xml | 2 +- ios/Runner.xcodeproj/project.pbxproj | 33 ++-------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ .../xcshareddata/WorkspaceSettings.xcsettings | 8 +++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++ .../xcshareddata/WorkspaceSettings.xcsettings | 8 +++ ios/Runner/Info.plist | 2 +- .../app_preferences/app_preferences_bloc.dart | 30 ++++++---- .../app_preferences_state.dart | 1 - .../authentication/authentication_bloc.dart | 16 +++-- .../authentication/authentication_state.dart | 17 +++--- .../board/board_home/board_home_bloc.dart | 6 +- .../board/board_home/board_home_state.dart | 4 +- .../board/comment_edit/comment_edit_bloc.dart | 6 +- .../comment_edit/comment_edit_state.dart | 28 ++++----- .../board/topic_detail/topic_detail_bloc.dart | 4 +- .../topic_detail/topic_detail_state.dart | 4 +- .../board/topic_edit/topic_edit_bloc.dart | 6 +- .../board/topic_edit/topic_edit_state.dart | 6 +- lib/blocs/storage/blocs.dart | 2 + .../storage/item_detail/item_detail_bloc.dart | 4 +- .../item_detail/item_detail_state.dart | 4 +- .../storage/item_edit/item_edit_state.dart | 3 + .../storage/item_form/item_form_bloc.dart | 14 ++--- .../storage/item_form/item_form_event.dart | 43 ++++++------- lib/blocs/storage/search/search_bloc.dart | 10 ++-- lib/blocs/storage/search/search_states.dart | 13 ++-- .../storage_detail/storage_detail_bloc.dart | 8 +-- .../storage_detail/storage_detail_state.dart | 5 +- .../storage_edit/storage_edit_state.dart | 3 + .../storage_form/storage_form_bloc.dart | 8 +-- .../storage_form/storage_form_event.dart | 26 ++++---- .../storage_home/storage_home_bloc.dart | 16 ++--- .../storage_home/storage_home_state.dart | 9 ++- lib/blocs/tab/tab_bloc.dart | 2 +- lib/blocs/tab/tab_event.dart | 6 +- lib/blocs/update/update_bloc.dart | 5 +- lib/blocs/update/update_state.dart | 18 +++--- lib/pages/blog/home_page.dart | 2 +- lib/pages/board/home_page.dart | 6 +- lib/pages/home_page.dart | 18 +++--- lib/pages/iot/home_page.dart | 2 +- lib/pages/login_page.dart | 60 ++++++++++--------- lib/pages/storage/home_page.dart | 8 +-- lib/pages/storage/item_edit_page.dart | 1 - lib/pages/storage/storage_datail_page.dart | 2 - lib/pages/storage/storage_edit_page.dart | 3 +- lib/pages/storage/widgets/item_form.dart | 38 ++++++------ lib/pages/storage/widgets/search_form.dart | 6 +- lib/pages/storage/widgets/storage_form.dart | 24 ++++---- .../storage/widgets/storage_item_list.dart | 1 - pubspec.yaml | 2 +- web/index.html | 2 +- web/manifest.json | 4 +- 60 files changed, 321 insertions(+), 280 deletions(-) rename android/app/src/main/kotlin/com/example/{home => smart_home}/MainActivity.kt (75%) create mode 100644 ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/.gitignore b/.gitignore index 1178ffd4..e5af7fa5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ # Flutter/Dart/Pub related **/doc/api/ +**/ios/Flutter/.last_build_id .dart_tool/ .flutter-plugins .flutter-plugins-dependencies @@ -33,6 +34,12 @@ # Web related lib/generated_plugin_registrant.dart +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + # Exceptions to above rules. !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/.metadata b/.metadata index 611c9ed3..897381f2 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: fabeb2a16f1d008ab8230f450c49141d35669798 - channel: beta + revision: 7736f3bc90270dcb0480db2ccffbf1d13c28db85 + channel: dev project_type: app diff --git a/CHANGELOG.md b/CHANGELOG.md index 72369e99..f1150036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,13 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +The format is based on [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/spec/v2.0.0.html). ## [Unreleased] +## [0.4.0] - 2020-07-16 + ### Added - 留言板(仅有添加话题和留言的功能) @@ -97,8 +99,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 利用 Flutter 编写的第一个可用的智慧家庭客户端 -[Unreleased]: https://github.com/he0119/smart-home-flutter/compare/v0.3.2...HEAD +[Unreleased]: https://github.com/he0119/smart-home-flutter/compare/v0.4.0...HEAD +[0.4.0]: https://github.com/he0119/smart-home-flutter/compare/v0.3.2...v0.4.0 [0.3.2]: https://github.com/he0119/smart-home-flutter/compare/v0.3.1...v0.3.2 [0.3.1]: https://github.com/he0119/smart-home-flutter/compare/v0.3.0...v0.3.1 [0.3.0]: https://github.com/he0119/smart-home-flutter/compare/v0.2.2...v0.3.0 diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 8f6f3797..d0e6fffc 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.smart_home"> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 21c23d8d..2af152f9 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.smart_home"> diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index b3bec350..87bb1a08 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -9,11 +9,7 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -26,8 +22,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -38,13 +32,11 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -57,8 +49,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -68,9 +58,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 9740EEB31CF90195004384FC /* Generated.xcconfig */, @@ -102,7 +90,6 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 97C147021CF9000F007C117D /* Info.plist */, - 97C146F11CF9000F007C117D /* Supporting Files */, 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, @@ -111,13 +98,6 @@ path = Runner; sourceTree = ""; }; - 97C146F11CF9000F007C117D /* Supporting Files */ = { - isa = PBXGroup; - children = ( - ); - name = "Supporting Files"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -157,7 +137,7 @@ }; }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -201,7 +181,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; @@ -253,7 +233,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -320,7 +299,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.home; + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartHome; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -330,7 +309,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -386,7 +364,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -454,7 +431,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.home; + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartHome; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -481,7 +458,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.home; + PRODUCT_BUNDLE_IDENTIFIER = com.example.smartHome; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 44ab78e9..e410c40e 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -11,7 +11,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - home + smart_home CFBundlePackageType APPL CFBundleShortVersionString diff --git a/lib/blocs/app_preferences/app_preferences_bloc.dart b/lib/blocs/app_preferences/app_preferences_bloc.dart index b03c47e2..2e7aec74 100644 --- a/lib/blocs/app_preferences/app_preferences_bloc.dart +++ b/lib/blocs/app_preferences/app_preferences_bloc.dart @@ -12,27 +12,31 @@ part 'app_preferences_state.dart'; class AppPreferencesBloc extends Bloc { static final Logger _log = Logger('AppPreferencesBloc'); - SharedPreferences _prefs; + Future _prefs = SharedPreferences.getInstance(); AppPreferencesBloc() : super(AppPreferencesState.initial()); - SharedPreferences get prefs => _prefs; - @override Stream mapEventToState( AppPreferencesEvent event, ) async* { if (event is AppStarted) { - // 初始化 SharedPreferences - _prefs = await SharedPreferences.getInstance().catchError((e) { - _log.severe('shared prefrences error : $e'); - throw Exception('shared prefrences error'); - }); - String apiUrl = _prefs.getString('apiUrl'); - yield state.copyWith(initialized: true, apiUrl: apiUrl); - } else if (event is AppApiUrlChanged) { - _prefs.setString('apiUrl', event.apiUrl); - yield state.copyWith(apiUrl: event.apiUrl); + try { + final SharedPreferences prefs = await _prefs; + String apiUrl = prefs.getString('apiUrl'); + yield state.copyWith(initialized: true, apiUrl: apiUrl); + } catch (e) { + _log.severe('启动失败,无法获取配置'); + } + } + if (event is AppApiUrlChanged) { + try { + final SharedPreferences prefs = await _prefs; + prefs.setString('apiUrl', event.apiUrl); + yield state.copyWith(apiUrl: event.apiUrl); + } catch (e) { + _log.severe('设置服务器网址失败'); + } } } } diff --git a/lib/blocs/app_preferences/app_preferences_state.dart b/lib/blocs/app_preferences/app_preferences_state.dart index 86c5857e..9638f273 100644 --- a/lib/blocs/app_preferences/app_preferences_state.dart +++ b/lib/blocs/app_preferences/app_preferences_state.dart @@ -19,7 +19,6 @@ class AppPreferencesState extends Equatable { AppPreferencesState copyWith({ bool initialized, String apiUrl, - String refreshToken, }) { return AppPreferencesState( initialized: initialized ?? this.initialized, diff --git a/lib/blocs/authentication/authentication_bloc.dart b/lib/blocs/authentication/authentication_bloc.dart index 1b431c9c..2d0f1903 100644 --- a/lib/blocs/authentication/authentication_bloc.dart +++ b/lib/blocs/authentication/authentication_bloc.dart @@ -13,7 +13,7 @@ class AuthenticationBloc AuthenticationBloc({ @required this.userRepository, - }) : super(AuthenticationUninitialized()); + }) : super(AuthenticationInitial()); @override Stream mapEventToState( @@ -32,12 +32,10 @@ class AuthenticationBloc try { // 检查是否登录 if (await userRepository.isLogin) { - yield Authenticated(await userRepository.currentUser()); + yield AuthenticationSuccess(await userRepository.currentUser()); } else { - yield Unauthenticated(); + yield AuthenticationFailure('未登录,请登录账户'); } - } on AuthenticationException catch (_) { - yield Unauthenticated(); } catch (e) { yield AuthenticationError(e.message); } @@ -45,23 +43,23 @@ class AuthenticationBloc Stream _mapLoginToState( AuthenticationLogin event) async* { - yield Authenticating(); + yield AuthenticationInProgress(); try { bool result = await userRepository.authenticate(event.username, event.password); if (result) { User user = await userRepository.currentUser(); - yield Authenticated(user); + yield AuthenticationSuccess(user); } else { yield AuthenticationFailure('用户名或密码错误'); } } catch (e) { - yield AuthenticationError(e.message); + yield AuthenticationFailure(e.message); } } Stream _mapLogoutToState() async* { + yield AuthenticationFailure('已登出'); await userRepository.logout(); - yield Unauthenticated(); } } diff --git a/lib/blocs/authentication/authentication_state.dart b/lib/blocs/authentication/authentication_state.dart index f0a4ae1f..763edb6a 100644 --- a/lib/blocs/authentication/authentication_state.dart +++ b/lib/blocs/authentication/authentication_state.dart @@ -7,14 +7,14 @@ abstract class AuthenticationState extends Equatable { List get props => []; } -class AuthenticationUninitialized extends AuthenticationState {} +class AuthenticationInitial extends AuthenticationState {} -class Authenticating extends AuthenticationState {} +class AuthenticationInProgress extends AuthenticationState {} -class Authenticated extends AuthenticationState { +class AuthenticationSuccess extends AuthenticationState { final User currentUser; - const Authenticated(this.currentUser); + const AuthenticationSuccess(this.currentUser); @override List get props => [currentUser]; @@ -23,10 +23,9 @@ class Authenticated extends AuthenticationState { String toString() => 'Authenticated { username: ${currentUser.username} }'; } -/// 未登录 -class Unauthenticated extends AuthenticationState {} - -/// 用户名密码错误 +/// 登陆失败 +/// +/// 用户名密码错误,或登录失效 class AuthenticationFailure extends AuthenticationState { final String message; @@ -36,7 +35,7 @@ class AuthenticationFailure extends AuthenticationState { List get props => [message]; @override - String toString() => 'AuthenticationFailure { error: $message }'; + String toString() => 'AuthenticationFailure { message: $message }'; } /// 网络错误 diff --git a/lib/blocs/board/board_home/board_home_bloc.dart b/lib/blocs/board/board_home/board_home_bloc.dart index fed88a11..90b753c3 100644 --- a/lib/blocs/board/board_home/board_home_bloc.dart +++ b/lib/blocs/board/board_home/board_home_bloc.dart @@ -20,10 +20,10 @@ class BoardHomeBloc extends Bloc { if (event is BoardHomeStarted) { try { yield BoardHomeInProgress(); - List topics = await boardRepository.topics(); + List topics = await boardRepository.topics(cache: false); yield BoardHomeSuccess(topics: topics); } catch (e) { - yield BoardHomeError(message: e.message); + yield BoardHomeFailure(e.message); } } if (event is BoardHomeRefreshed) { @@ -32,7 +32,7 @@ class BoardHomeBloc extends Bloc { List topics = await boardRepository.topics(cache: false); yield BoardHomeSuccess(topics: topics); } catch (e) { - yield BoardHomeError(message: e.message); + yield BoardHomeFailure(e.message); } } } diff --git a/lib/blocs/board/board_home/board_home_state.dart b/lib/blocs/board/board_home/board_home_state.dart index d6013e55..646894a6 100644 --- a/lib/blocs/board/board_home/board_home_state.dart +++ b/lib/blocs/board/board_home/board_home_state.dart @@ -9,10 +9,10 @@ abstract class BoardHomeState extends Equatable { class BoardHomeInProgress extends BoardHomeState {} -class BoardHomeError extends BoardHomeState { +class BoardHomeFailure extends BoardHomeState { final String message; - const BoardHomeError({@required this.message}); + const BoardHomeFailure(this.message); @override List get props => [message]; diff --git a/lib/blocs/board/comment_edit/comment_edit_bloc.dart b/lib/blocs/board/comment_edit/comment_edit_bloc.dart index 8854fad2..2d6be373 100644 --- a/lib/blocs/board/comment_edit/comment_edit_bloc.dart +++ b/lib/blocs/board/comment_edit/comment_edit_bloc.dart @@ -27,7 +27,7 @@ class CommentEditBloc extends Bloc { ); yield CommentAddSuccess(comment: comment); } catch (e) { - yield CommentError(message: e.message); + yield CommentFailure(e.message); } } if (event is CommentUpdated) { @@ -39,7 +39,7 @@ class CommentEditBloc extends Bloc { ); yield CommentUpdateSuccess(comment: comment); } catch (e) { - yield CommentError(message: e.message); + yield CommentFailure(e.message); } } if (event is CommentDeleted) { @@ -48,7 +48,7 @@ class CommentEditBloc extends Bloc { await boardRepository.deleteComment(commentId: event.comment.id); yield CommentDeleteSuccess(comment: event.comment); } catch (e) { - yield CommentError(message: e.message); + yield CommentFailure(e.message); } } } diff --git a/lib/blocs/board/comment_edit/comment_edit_state.dart b/lib/blocs/board/comment_edit/comment_edit_state.dart index cd0061cc..c0a8889b 100644 --- a/lib/blocs/board/comment_edit/comment_edit_state.dart +++ b/lib/blocs/board/comment_edit/comment_edit_state.dart @@ -11,6 +11,20 @@ class CommentInitial extends CommentEditState {} class CommentInProgress extends CommentEditState {} +class CommentFailure extends CommentEditState { + final String message; + + const CommentFailure(this.message); + + @override + List get props => [message]; + + @override + String toString() { + return 'CommentFailure { $message }'; + } +} + class CommentAddSuccess extends CommentEditState { final Comment comment; @@ -37,17 +51,3 @@ class CommentDeleteSuccess extends CommentEditState { @override List get props => [comment]; } - -class CommentError extends CommentEditState { - final String message; - - const CommentError({@required this.message}); - - @override - List get props => [message]; - - @override - String toString() { - return 'TopicError { $message }'; - } -} diff --git a/lib/blocs/board/topic_detail/topic_detail_bloc.dart b/lib/blocs/board/topic_detail/topic_detail_bloc.dart index 5a54bf85..1bd749a4 100644 --- a/lib/blocs/board/topic_detail/topic_detail_bloc.dart +++ b/lib/blocs/board/topic_detail/topic_detail_bloc.dart @@ -26,7 +26,7 @@ class TopicDetailBloc extends Bloc { topic: topicDetail[0], comments: topicDetail[1]); } catch (e) { yield TopicDetailFailure( - message: e.message, + e.message, topicId: event.topicId, ); } @@ -40,7 +40,7 @@ class TopicDetailBloc extends Bloc { topic: topicDetail[0], comments: topicDetail[1]); } catch (e) { yield TopicDetailFailure( - message: e.message, + e.message, topicId: event.topicId, ); } diff --git a/lib/blocs/board/topic_detail/topic_detail_state.dart b/lib/blocs/board/topic_detail/topic_detail_state.dart index 558a92a0..3672008d 100644 --- a/lib/blocs/board/topic_detail/topic_detail_state.dart +++ b/lib/blocs/board/topic_detail/topic_detail_state.dart @@ -13,8 +13,8 @@ class TopicDetailFailure extends TopicDetailState { final String message; final String topicId; - const TopicDetailFailure({ - @required this.message, + const TopicDetailFailure( + this.message, { @required this.topicId, }); diff --git a/lib/blocs/board/topic_edit/topic_edit_bloc.dart b/lib/blocs/board/topic_edit/topic_edit_bloc.dart index fac15d22..6867368c 100644 --- a/lib/blocs/board/topic_edit/topic_edit_bloc.dart +++ b/lib/blocs/board/topic_edit/topic_edit_bloc.dart @@ -27,7 +27,7 @@ class TopicEditBloc extends Bloc { ); yield TopicAddSuccess(topic: topic); } catch (e) { - yield TopicError(message: e.message); + yield TopicFailure(e.message); } } if (event is TopicUpdated) { @@ -40,7 +40,7 @@ class TopicEditBloc extends Bloc { ); yield TopicUpdateSuccess(topic: topic); } catch (e) { - yield TopicError(message: e.message); + yield TopicFailure(e.message); } } if (event is TopicDeleted) { @@ -49,7 +49,7 @@ class TopicEditBloc extends Bloc { await boardRepository.deleteTopic(topicId: event.topic.id); yield TopicDeleteSuccess(topic: event.topic); } catch (e) { - yield TopicError(message: e.message); + yield TopicFailure(e.message); } } } diff --git a/lib/blocs/board/topic_edit/topic_edit_state.dart b/lib/blocs/board/topic_edit/topic_edit_state.dart index 0ffe61d8..06c477a9 100644 --- a/lib/blocs/board/topic_edit/topic_edit_state.dart +++ b/lib/blocs/board/topic_edit/topic_edit_state.dart @@ -11,17 +11,17 @@ class TopicInitial extends TopicEditState {} class TopicInProgress extends TopicEditState {} -class TopicError extends TopicEditState { +class TopicFailure extends TopicEditState { final String message; - const TopicError({@required this.message}); + const TopicFailure(this.message); @override List get props => [message]; @override String toString() { - return 'TopicError { $message }'; + return 'TopicFailure { $message }'; } } diff --git a/lib/blocs/storage/blocs.dart b/lib/blocs/storage/blocs.dart index c1745b0f..3574ed78 100644 --- a/lib/blocs/storage/blocs.dart +++ b/lib/blocs/storage/blocs.dart @@ -1,6 +1,8 @@ export 'item_detail/item_detail_bloc.dart'; export 'item_edit/item_edit_bloc.dart'; +export 'item_form/item_form_bloc.dart'; export 'search/search_bloc.dart'; export 'storage_detail/storage_detail_bloc.dart'; export 'storage_edit/storage_edit_bloc.dart'; +export 'storage_form/storage_form_bloc.dart'; export 'storage_home/storage_home_bloc.dart'; diff --git a/lib/blocs/storage/item_detail/item_detail_bloc.dart b/lib/blocs/storage/item_detail/item_detail_bloc.dart index c1823636..1bc59859 100644 --- a/lib/blocs/storage/item_detail/item_detail_bloc.dart +++ b/lib/blocs/storage/item_detail/item_detail_bloc.dart @@ -23,7 +23,7 @@ class ItemDetailBloc extends Bloc { yield ItemDetailSuccess(item: results); } catch (e) { yield ItemDetailFailure( - message: e.message, + e.message, itemId: event.itemId, ); } @@ -38,7 +38,7 @@ class ItemDetailBloc extends Bloc { yield ItemDetailSuccess(item: results); } catch (e) { yield ItemDetailFailure( - message: e.message, + e.message, itemId: event.itemId, ); } diff --git a/lib/blocs/storage/item_detail/item_detail_state.dart b/lib/blocs/storage/item_detail/item_detail_state.dart index b0f2b81d..bcbb4cb5 100644 --- a/lib/blocs/storage/item_detail/item_detail_state.dart +++ b/lib/blocs/storage/item_detail/item_detail_state.dart @@ -13,8 +13,8 @@ class ItemDetailFailure extends ItemDetailState { final String message; final String itemId; - const ItemDetailFailure({ - @required this.message, + const ItemDetailFailure( + this.message, { @required this.itemId, }); diff --git a/lib/blocs/storage/item_edit/item_edit_state.dart b/lib/blocs/storage/item_edit/item_edit_state.dart index cf00e134..bfcf5805 100644 --- a/lib/blocs/storage/item_edit/item_edit_state.dart +++ b/lib/blocs/storage/item_edit/item_edit_state.dart @@ -15,6 +15,9 @@ class ItemEditFailure extends ItemEditState { final String message; const ItemEditFailure(this.message); + + @override + String toString() => 'ItemEditFailure { message: $message }'; } class ItemAddSuccess extends ItemEditState { diff --git a/lib/blocs/storage/item_form/item_form_bloc.dart b/lib/blocs/storage/item_form/item_form_bloc.dart index efb3c699..a7723b9e 100644 --- a/lib/blocs/storage/item_form/item_form_bloc.dart +++ b/lib/blocs/storage/item_form/item_form_bloc.dart @@ -24,37 +24,37 @@ class ItemFormBloc extends Bloc { if (event is ItemFormStarted) { yield state.copyWith(listofStorages: await storageRepository.storages()); } - if (event is NameChanged) { + if (event is ItemNameChanged) { yield state.copyWith( name: event.name, isNameValid: _isNameValid(event.name), ); } - if (event is NumberChanged) { + if (event is ItemNumberChanged) { yield state.copyWith( number: event.number, isNumberValid: _isNumberValid(event.number), ); } - if (event is PriceChanged) { + if (event is ItemPriceChanged) { yield state.copyWith( price: event.price, isPriceValid: _isPriceValid(event.price), ); } - if (event is DescriptionChanged) { + if (event is ItemDescriptionChanged) { yield state.copyWith( description: event.description, isDescriptionValid: true, ); } - if (event is StorageChanged) { + if (event is ItemStorageChanged) { yield state.copyWith( storage: event.storage, isStorageValid: _isStorageValid(event.storage), ); } - if (event is ExpirationDateChanged) { + if (event is ItemExpirationDateChanged) { yield ItemFormState( name: state.name, isNameValid: state.isNameValid, @@ -71,7 +71,7 @@ class ItemFormBloc extends Bloc { listofStorages: state.listofStorages, ); } - if (event is FormSubmitted) { + if (event is ItemFormSubmitted) { double price; if (state.price != null && state.price.isNotEmpty) { price = double.parse(state.price); diff --git a/lib/blocs/storage/item_form/item_form_event.dart b/lib/blocs/storage/item_form/item_form_event.dart index 2675fcd3..97dfb7b1 100644 --- a/lib/blocs/storage/item_form/item_form_event.dart +++ b/lib/blocs/storage/item_form/item_form_event.dart @@ -9,89 +9,90 @@ abstract class ItemFormEvent extends Equatable { class ItemFormStarted extends ItemFormEvent {} -class NameChanged extends ItemFormEvent { +class ItemNameChanged extends ItemFormEvent { final String name; - const NameChanged({@required this.name}); + const ItemNameChanged({@required this.name}); @override List get props => [name]; @override - String toString() => 'NameChanged { name: $name }'; + String toString() => 'ItemNameChanged { name: $name }'; } -class NumberChanged extends ItemFormEvent { +class ItemNumberChanged extends ItemFormEvent { final String number; - const NumberChanged({@required this.number}); + const ItemNumberChanged({@required this.number}); @override List get props => [number]; @override - String toString() => 'NumberChanged { number: $number }'; + String toString() => 'ItemNumberChanged { number: $number }'; } -class StorageChanged extends ItemFormEvent { +class ItemStorageChanged extends ItemFormEvent { final String storage; - const StorageChanged({@required this.storage}); + const ItemStorageChanged({@required this.storage}); @override List get props => [storage]; @override - String toString() => 'StorageChanged { storage_id: $storage }'; + String toString() => 'ItemStorageChanged { storage_id: $storage }'; } -class DescriptionChanged extends ItemFormEvent { +class ItemDescriptionChanged extends ItemFormEvent { final String description; - const DescriptionChanged({@required this.description}); + const ItemDescriptionChanged({@required this.description}); @override List get props => [description]; @override - String toString() => 'DescriptionChanged { description: $description }'; + String toString() => 'ItemDescriptionChanged { description: $description }'; } -class PriceChanged extends ItemFormEvent { +class ItemPriceChanged extends ItemFormEvent { final String price; - const PriceChanged({@required this.price}); + const ItemPriceChanged({@required this.price}); @override List get props => [price]; @override - String toString() => 'PriceChanged { price: $price }'; + String toString() => 'ItemPriceChanged { price: $price }'; } -class ExpirationDateChanged extends ItemFormEvent { +class ItemExpirationDateChanged extends ItemFormEvent { final DateTime expirationDate; - const ExpirationDateChanged({@required this.expirationDate}); + const ItemExpirationDateChanged({@required this.expirationDate}); @override List get props => [expirationDate]; @override String toString() => - 'ExpirationDateChanged { expirationDate: $expirationDate }'; + 'ItemExpirationDateChanged { expirationDate: $expirationDate }'; } -class FormSubmitted extends ItemFormEvent { +class ItemFormSubmitted extends ItemFormEvent { final bool isEditing; final String id; final String oldStorageId; - const FormSubmitted({@required this.isEditing, this.id, this.oldStorageId}); + const ItemFormSubmitted( + {@required this.isEditing, this.id, this.oldStorageId}); @override List get props => [isEditing, id, oldStorageId]; @override - String toString() => 'FormSubmitted { item id: $id }'; + String toString() => 'ItemFormSubmitted { item id: $id }'; } diff --git a/lib/blocs/storage/search/search_bloc.dart b/lib/blocs/storage/search/search_bloc.dart index abc10dc5..4534765c 100644 --- a/lib/blocs/storage/search/search_bloc.dart +++ b/lib/blocs/storage/search/search_bloc.dart @@ -10,25 +10,25 @@ part 'search_states.dart'; class StorageSearchBloc extends Bloc { final StorageRepository storageRepository; StorageSearchBloc({@required this.storageRepository}) - : super(StorageSearchResults(items: [], storages: [], term: '')); + : super(StorageSearchSuccess(items: [], storages: [], term: '')); @override Stream mapEventToState(StorageSearchEvent event) async* { if (event is StorageSearchChanged) { if (event.key.isEmpty) { - yield StorageSearchResults(items: [], storages: [], term: ''); + yield StorageSearchSuccess(items: [], storages: [], term: ''); return; } - yield StorageSearchLoading(); + yield StorageSearchInProgress(); try { List results = await storageRepository.search(event.key); - yield StorageSearchResults( + yield StorageSearchSuccess( items: results[0], storages: results[1], term: event.key, ); } catch (e) { - yield StorageSearchError(e.message); + yield StorageSearchFailure(e.message); } } } diff --git a/lib/blocs/storage/search/search_states.dart b/lib/blocs/storage/search/search_states.dart index d5be5e05..f2c36981 100644 --- a/lib/blocs/storage/search/search_states.dart +++ b/lib/blocs/storage/search/search_states.dart @@ -7,23 +7,26 @@ abstract class StorageSearchState extends Equatable { List get props => []; } -class StorageSearchLoading extends StorageSearchState {} +class StorageSearchInProgress extends StorageSearchState {} -class StorageSearchError extends StorageSearchState { +class StorageSearchFailure extends StorageSearchState { final String message; - const StorageSearchError(this.message); + const StorageSearchFailure(this.message); @override List get props => [message]; + + @override + String toString() => 'StorageSearchFailure { message: $message }'; } -class StorageSearchResults extends StorageSearchState { +class StorageSearchSuccess extends StorageSearchState { final List items; final List storages; final String term; - StorageSearchResults({ + StorageSearchSuccess({ @required this.items, @required this.storages, @required this.term, diff --git a/lib/blocs/storage/storage_detail/storage_detail_bloc.dart b/lib/blocs/storage/storage_detail/storage_detail_bloc.dart index ebd22b00..0f31e8fa 100644 --- a/lib/blocs/storage/storage_detail/storage_detail_bloc.dart +++ b/lib/blocs/storage/storage_detail/storage_detail_bloc.dart @@ -29,7 +29,7 @@ class StorageDetailBloc extends Bloc { yield StorageDetailRootSuccess(storages: results); } catch (e) { yield StorageDetailFailure( - message: e.message, + e.message, storageId: null, ); } @@ -43,7 +43,7 @@ class StorageDetailBloc extends Bloc { yield StorageDetailRootSuccess(storages: results); } catch (e) { yield StorageDetailFailure( - message: e.message, + e.message, storageId: null, ); } @@ -66,7 +66,7 @@ class StorageDetailBloc extends Bloc { ); } catch (e) { yield StorageDetailFailure( - message: e.message, + e.message, storageId: event.id, ); } @@ -85,7 +85,7 @@ class StorageDetailBloc extends Bloc { ); } catch (e) { yield StorageDetailFailure( - message: e.message, + e.message, storageId: event.id, ); } diff --git a/lib/blocs/storage/storage_detail/storage_detail_state.dart b/lib/blocs/storage/storage_detail/storage_detail_state.dart index 1f44be19..324e1309 100644 --- a/lib/blocs/storage/storage_detail/storage_detail_state.dart +++ b/lib/blocs/storage/storage_detail/storage_detail_state.dart @@ -13,10 +13,11 @@ class StorageDetailFailure extends StorageDetailState { final String message; final String storageId; - const StorageDetailFailure({ - @required this.message, + const StorageDetailFailure( + this.message, { @required this.storageId, }); + @override String toString() => 'StorageDetailFailure { message: $message }'; } diff --git a/lib/blocs/storage/storage_edit/storage_edit_state.dart b/lib/blocs/storage/storage_edit/storage_edit_state.dart index 9c8880b3..2e9c6e42 100644 --- a/lib/blocs/storage/storage_edit/storage_edit_state.dart +++ b/lib/blocs/storage/storage_edit/storage_edit_state.dart @@ -15,6 +15,9 @@ class StorageEditFailure extends StorageEditState { final String message; const StorageEditFailure(this.message); + + @override + String toString() => 'StorageEditFailure { message: $message }'; } class StorageAddSuccess extends StorageEditState {} diff --git a/lib/blocs/storage/storage_form/storage_form_bloc.dart b/lib/blocs/storage/storage_form/storage_form_bloc.dart index 6a03c101..ab86b8ff 100644 --- a/lib/blocs/storage/storage_form/storage_form_bloc.dart +++ b/lib/blocs/storage/storage_form/storage_form_bloc.dart @@ -24,25 +24,25 @@ class StorageFormBloc extends Bloc { if (event is StorageFormStarted) { yield state.copyWith(listofStorages: await storageRepository.storages()); } - if (event is NameChanged) { + if (event is StorageNameChanged) { yield state.copyWith( name: event.name, isNameValid: _isNameValid(event.name), ); } - if (event is DescriptionChanged) { + if (event is StorageDescriptionChanged) { yield state.copyWith( description: event.description, isDescriptionValid: true, ); } - if (event is ParentChanged) { + if (event is StorageParentChanged) { yield state.copyWith( parent: event.parent, isParentValid: _isStorageValid(event.parent), ); } - if (event is FormSubmitted) { + if (event is StorageFormSubmitted) { if (event.isEditing) { storageEditBloc.add( StorageUpdated( diff --git a/lib/blocs/storage/storage_form/storage_form_event.dart b/lib/blocs/storage/storage_form/storage_form_event.dart index 2f2c7ddf..51325fc0 100644 --- a/lib/blocs/storage/storage_form/storage_form_event.dart +++ b/lib/blocs/storage/storage_form/storage_form_event.dart @@ -9,52 +9,54 @@ abstract class StorageFormEvent extends Equatable { class StorageFormStarted extends StorageFormEvent {} -class NameChanged extends StorageFormEvent { +class StorageNameChanged extends StorageFormEvent { final String name; - const NameChanged({@required this.name}); + const StorageNameChanged({@required this.name}); @override List get props => [name]; @override - String toString() => 'NameChanged { name: $name }'; + String toString() => 'StorageNameChanged { name: $name }'; } -class ParentChanged extends StorageFormEvent { +class StorageParentChanged extends StorageFormEvent { final String parent; - const ParentChanged({@required this.parent}); + const StorageParentChanged({@required this.parent}); @override List get props => [parent]; @override - String toString() => 'ParentChanged { parent_id: $parent }'; + String toString() => 'StorageParentChanged { parent_id: $parent }'; } -class DescriptionChanged extends StorageFormEvent { +class StorageDescriptionChanged extends StorageFormEvent { final String description; - const DescriptionChanged({@required this.description}); + const StorageDescriptionChanged({@required this.description}); @override List get props => [description]; @override - String toString() => 'DescriptionChanged { description: $description }'; + String toString() => + 'StorageDescriptionChanged { description: $description }'; } -class FormSubmitted extends StorageFormEvent { +class StorageFormSubmitted extends StorageFormEvent { final bool isEditing; final String id; final String oldParentId; - const FormSubmitted({@required this.isEditing, this.id, this.oldParentId}); + const StorageFormSubmitted( + {@required this.isEditing, this.id, this.oldParentId}); @override List get props => [isEditing, id, oldParentId]; @override - String toString() => 'FormSubmitted { item id: $id }'; + String toString() => 'StorageFormSubmitted { item id: $id }'; } diff --git a/lib/blocs/storage/storage_home/storage_home_bloc.dart b/lib/blocs/storage/storage_home/storage_home_bloc.dart index 01d6a68f..e87a6550 100644 --- a/lib/blocs/storage/storage_home/storage_home_bloc.dart +++ b/lib/blocs/storage/storage_home/storage_home_bloc.dart @@ -20,8 +20,10 @@ class StorageHomeBloc extends Bloc { StorageHomeEvent event, ) async* { if (event is StorageHomeStarted) { + yield StorageHomeInProgress(); try { - Map> homepage = await storageRepository.homePage(); + Map> homepage = + await storageRepository.homePage(cache: false); yield StorageHomeSuccess( recentlyAddedItems: homepage['recentlyAddedItems'], recentlyUpdatedItems: homepage['recentlyUpdatedItems'], @@ -30,8 +32,8 @@ class StorageHomeBloc extends Bloc { itemType: ItemType.all, ); } catch (e) { - yield StorageHomeError( - message: e.message, + yield StorageHomeFailure( + e.message, itemType: ItemType.all, ); } @@ -84,8 +86,8 @@ class StorageHomeBloc extends Bloc { break; } } catch (e) { - yield StorageHomeError( - message: e.message, + yield StorageHomeFailure( + e.message, itemType: event.itemType, ); } @@ -145,8 +147,8 @@ class StorageHomeBloc extends Bloc { break; } } catch (e) { - yield StorageHomeError( - message: e.message, + yield StorageHomeFailure( + e.message, itemType: event.itemType, ); } diff --git a/lib/blocs/storage/storage_home/storage_home_state.dart b/lib/blocs/storage/storage_home/storage_home_state.dart index 346e6618..1f03fdf7 100644 --- a/lib/blocs/storage/storage_home/storage_home_state.dart +++ b/lib/blocs/storage/storage_home/storage_home_state.dart @@ -9,17 +9,20 @@ abstract class StorageHomeState extends Equatable { class StorageHomeInProgress extends StorageHomeState {} -class StorageHomeError extends StorageHomeState { +class StorageHomeFailure extends StorageHomeState { final String message; final ItemType itemType; - const StorageHomeError({ - @required this.message, + const StorageHomeFailure( + this.message, { @required this.itemType, }); @override List get props => [message, itemType]; + + @override + String toString() => 'StorageHomeFailure { message: $message }'; } class StorageHomeSuccess extends StorageHomeState { diff --git a/lib/blocs/tab/tab_bloc.dart b/lib/blocs/tab/tab_bloc.dart index 34c6b4a4..6f89dbe0 100644 --- a/lib/blocs/tab/tab_bloc.dart +++ b/lib/blocs/tab/tab_bloc.dart @@ -9,7 +9,7 @@ class TabBloc extends Bloc { @override Stream mapEventToState(TabEvent event) async* { - if (event is UpdateTab) { + if (event is TabChanged) { yield event.tab; } } diff --git a/lib/blocs/tab/tab_event.dart b/lib/blocs/tab/tab_event.dart index 92c1525b..c1cdd892 100644 --- a/lib/blocs/tab/tab_event.dart +++ b/lib/blocs/tab/tab_event.dart @@ -4,14 +4,14 @@ abstract class TabEvent extends Equatable { const TabEvent(); } -class UpdateTab extends TabEvent { +class TabChanged extends TabEvent { final AppTab tab; - const UpdateTab(this.tab); + const TabChanged(this.tab); @override List get props => [tab]; @override - String toString() => 'UpdateTab { tab: $tab }'; + String toString() => 'TabUpdated { tab: $tab }'; } diff --git a/lib/blocs/update/update_bloc.dart b/lib/blocs/update/update_bloc.dart index f64d0be2..5bfe52e9 100644 --- a/lib/blocs/update/update_bloc.dart +++ b/lib/blocs/update/update_bloc.dart @@ -11,12 +11,11 @@ part 'update_state.dart'; class UpdateBloc extends Bloc { VersionRepository versionRepository; + UpdateBloc({@required this.versionRepository}) : super(UpdateInitial()); @override - Stream mapEventToState( - UpdateEvent event, - ) async* { + Stream mapEventToState(UpdateEvent event) async* { // 暂时只支持 Android if (event is UpdateStarted && !kIsWeb && Platform.isAndroid) { try { diff --git a/lib/blocs/update/update_state.dart b/lib/blocs/update/update_state.dart index f4d2298c..45c7b581 100644 --- a/lib/blocs/update/update_state.dart +++ b/lib/blocs/update/update_state.dart @@ -8,6 +8,15 @@ class UpdateInitial extends UpdateState { String toString() => 'UpdateInitial'; } +class UpdateFailure extends UpdateState { + final String message; + + UpdateFailure(this.message); + + @override + String toString() => 'UpdateFailure { message: $message }'; +} + class UpdateSuccess extends UpdateState { final bool needUpdate; final String url; @@ -19,12 +28,3 @@ class UpdateSuccess extends UpdateState { String toString() => 'UpdateSuccess { needUpdate: $needUpdate, version: $version }'; } - -class UpdateFailure extends UpdateState { - final String message; - - UpdateFailure(this.message); - - @override - String toString() => 'UpdateError { message: $message }'; -} diff --git a/lib/pages/blog/home_page.dart b/lib/pages/blog/home_page.dart index 92a02acc..bbd9af19 100644 --- a/lib/pages/blog/home_page.dart +++ b/lib/pages/blog/home_page.dart @@ -22,7 +22,7 @@ class BlogHomePage extends StatelessWidget { bottomNavigationBar: TabSelector( activeTab: AppTab.blog, onTabSelected: (tab) => - BlocProvider.of(context).add(UpdateTab(tab)), + BlocProvider.of(context).add(TabChanged(tab)), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.open_in_new), diff --git a/lib/pages/board/home_page.dart b/lib/pages/board/home_page.dart index 97c94fef..b0d55ebf 100644 --- a/lib/pages/board/home_page.dart +++ b/lib/pages/board/home_page.dart @@ -20,7 +20,7 @@ class BoardHomePage extends StatelessWidget { builder: (context, state) => Scaffold( key: scaffoldKey, appBar: AppBar( - leading: state is Authenticated + leading: state is AuthenticationSuccess ? IconButton( icon: CircleGravatar(email: state.currentUser.email), onPressed: null, @@ -32,7 +32,7 @@ class BoardHomePage extends StatelessWidget { bottomNavigationBar: TabSelector( activeTab: AppTab.board, onTabSelected: (tab) => - BlocProvider.of(context).add(UpdateTab(tab)), + BlocProvider.of(context).add(TabChanged(tab)), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.create), @@ -58,7 +58,7 @@ class _BoardHomeBody extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - if (state is BoardHomeError) { + if (state is BoardHomeFailure) { return ErrorPage( onPressed: () { BlocProvider.of(context).add(BoardHomeRefreshed()); diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index aa5662fd..18a042e7 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -25,18 +25,22 @@ class HomePage extends StatelessWidget { create: (context) => AuthenticationBloc( userRepository: RepositoryProvider.of(context), )..add(AuthenticationStarted()), - child: BlocBuilder( + child: BlocConsumer( + listener: (context, state) { + if (state is AuthenticationFailure) { + Navigator.of(context).popUntil((route) => route.isFirst); + } + }, builder: (context, state) { // 用户仓库同时也需要认证 BLoC 来处理认证相关逻辑 // 在首次启动的时候将认证 BLoC 提供给用户仓库 - if (state is AuthenticationUninitialized) { + if (state is AuthenticationInitial) { RepositoryProvider.of(context).authenticationBloc = BlocProvider.of(context); return SplashPage(); } - // 仅在未登录,登陆失败和登陆中进入登陆界面 - if (state is Unauthenticated || - state is Authenticating || + // 仅在登陆失败和登陆中进入登陆界面 + if (state is AuthenticationInProgress || state is AuthenticationFailure) { return LoginPage(); } @@ -88,9 +92,9 @@ class _HomePage extends StatelessWidget { final QuickActions quickActions = QuickActions(); quickActions.initialize((String shortcutType) async { if (shortcutType == 'action_iot') { - BlocProvider.of(context).add(UpdateTab(AppTab.iot)); + BlocProvider.of(context).add(TabChanged(AppTab.iot)); } else { - BlocProvider.of(context).add(UpdateTab(AppTab.blog)); + BlocProvider.of(context).add(TabChanged(AppTab.blog)); } }); quickActions.setShortcutItems( diff --git a/lib/pages/iot/home_page.dart b/lib/pages/iot/home_page.dart index fd9c78de..eb6949f3 100644 --- a/lib/pages/iot/home_page.dart +++ b/lib/pages/iot/home_page.dart @@ -19,7 +19,7 @@ class IotHomePage extends StatelessWidget { bottomNavigationBar: TabSelector( activeTab: AppTab.iot, onTabSelected: (tab) => - BlocProvider.of(context).add(UpdateTab(tab)), + BlocProvider.of(context).add(TabChanged(tab)), ), ); } diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 4de15408..30142848 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -16,32 +16,39 @@ class _LoginPageState extends State { Widget build(BuildContext context) { AppConfig appConfig = AppConfig.of(context); return Scaffold( - body: BlocBuilder( - builder: (context, state) { - if (state.apiUrl == null) { - canLogin = false; + body: BlocListener( + listener: (context, state) { + if (state is AuthenticationFailure) { + showErrorSnackBar(context, state.message); } - return canLogin - ? LoginForm(onTapBack: () { - setState(() { - canLogin = false; - }); - }) - : ApiUrlForm( - apiUrl: state.apiUrl ?? appConfig.apiUrl, - onTapNext: () { + }, + child: BlocBuilder( + builder: (context, state) { + if (state.apiUrl == null) { + canLogin = false; + } + return canLogin + ? LoginForm(onTapBack: () { setState(() { - canLogin = true; + canLogin = false; }); - }, - ); - }, + }) + : ApiUrlForm( + apiUrl: state.apiUrl ?? appConfig.apiUrl, + onTapNext: () { + setState(() { + canLogin = true; + }); + }, + ); + }, + ), ), ); } } -/// 选择 APIURL 的界面 +/// 选择服务器网址的界面 class ApiUrlForm extends StatefulWidget { final String apiUrl; final Function onTapNext; @@ -158,12 +165,7 @@ class _LoginFormState extends State { ); } - return BlocConsumer( - listener: (context, state) { - if (state is AuthenticationFailure) { - showErrorSnackBar(context, state.message); - } - }, + return BlocBuilder( builder: (context, state) { return Column( mainAxisAlignment: MainAxisAlignment.center, @@ -202,8 +204,9 @@ class _LoginFormState extends State { shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(18.0), ), - onPressed: - state is! Authenticating ? _onLoginButtonPressed : null, + onPressed: state is! AuthenticationInProgress + ? _onLoginButtonPressed + : null, child: Text('登录'), ), FlatButton( @@ -211,8 +214,9 @@ class _LoginFormState extends State { child: Text('返回'), ), Container( - child: - state is Authenticating ? CircularProgressIndicator() : null, + child: state is AuthenticationInProgress + ? CircularProgressIndicator() + : null, ), ], ); diff --git a/lib/pages/storage/home_page.dart b/lib/pages/storage/home_page.dart index ffbe6a9d..e1aa53b6 100644 --- a/lib/pages/storage/home_page.dart +++ b/lib/pages/storage/home_page.dart @@ -24,7 +24,7 @@ class StorageHomePage extends StatelessWidget { builder: (context, state) => Scaffold( key: scaffoldKey, appBar: AppBar( - leading: state is Authenticated + leading: state is AuthenticationSuccess ? IconButton( icon: CircleGravatar(email: state.currentUser.email), onPressed: null, @@ -47,7 +47,7 @@ class StorageHomePage extends StatelessWidget { bottomNavigationBar: TabSelector( activeTab: AppTab.storage, onTabSelected: (tab) => - BlocProvider.of(context).add(UpdateTab(tab)), + BlocProvider.of(context).add(TabChanged(tab)), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.storage), @@ -72,7 +72,7 @@ class _StorageHomeBody extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - if (state is StorageHomeError) { + if (state is StorageHomeFailure) { return ErrorPage( onPressed: () { BlocProvider.of(context).add( @@ -90,7 +90,7 @@ class _StorageHomeBody extends StatelessWidget { return true; } BlocProvider.of(context) - .add(StorageHomeRefreshed(itemType: ItemType.all)); + .add(StorageHomeChanged(itemType: ItemType.all)); return false; }, child: RefreshIndicator( diff --git a/lib/pages/storage/item_edit_page.dart b/lib/pages/storage/item_edit_page.dart index 8d721f0a..20cb169d 100644 --- a/lib/pages/storage/item_edit_page.dart +++ b/lib/pages/storage/item_edit_page.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:smart_home/blocs/blocs.dart'; import 'package:smart_home/blocs/storage/blocs.dart'; -import 'package:smart_home/blocs/storage/item_form/item_form_bloc.dart'; import 'package:smart_home/models/models.dart'; import 'package:smart_home/models/storage.dart'; import 'package:smart_home/pages/storage/widgets/item_form.dart'; diff --git a/lib/pages/storage/storage_datail_page.dart b/lib/pages/storage/storage_datail_page.dart index 2000c5d0..76216675 100644 --- a/lib/pages/storage/storage_datail_page.dart +++ b/lib/pages/storage/storage_datail_page.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:smart_home/blocs/blocs.dart'; import 'package:smart_home/blocs/storage/blocs.dart'; -import 'package:smart_home/blocs/storage/storage_detail/storage_detail_bloc.dart'; -import 'package:smart_home/blocs/storage/storage_edit/storage_edit_bloc.dart'; import 'package:smart_home/models/detail_page_menu.dart'; import 'package:smart_home/models/models.dart'; import 'package:smart_home/pages/error_page.dart'; diff --git a/lib/pages/storage/storage_edit_page.dart b/lib/pages/storage/storage_edit_page.dart index 21ca2797..462ef326 100644 --- a/lib/pages/storage/storage_edit_page.dart +++ b/lib/pages/storage/storage_edit_page.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:smart_home/blocs/blocs.dart'; -import 'package:smart_home/blocs/storage/storage_edit/storage_edit_bloc.dart'; -import 'package:smart_home/blocs/storage/storage_form/storage_form_bloc.dart'; +import 'package:smart_home/blocs/storage/blocs.dart'; import 'package:smart_home/models/models.dart'; import 'package:smart_home/models/storage.dart'; import 'package:smart_home/pages/storage/widgets/storage_form.dart'; diff --git a/lib/pages/storage/widgets/item_form.dart b/lib/pages/storage/widgets/item_form.dart index 98cb7d39..0e73c8f6 100644 --- a/lib/pages/storage/widgets/item_form.dart +++ b/lib/pages/storage/widgets/item_form.dart @@ -4,7 +4,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; import 'package:smart_home/blocs/storage/blocs.dart'; -import 'package:smart_home/blocs/storage/item_form/item_form_bloc.dart'; import 'package:smart_home/models/models.dart'; class ItemForm extends StatefulWidget { @@ -45,7 +44,7 @@ class _ItemFormState extends State { TextFormField( initialValue: widget.isEditing ? widget.item.name : '', onChanged: (value) => - _itemFormBloc.add(NameChanged(name: value)), + _itemFormBloc.add(ItemNameChanged(name: value)), decoration: InputDecoration( labelText: '名称', ), @@ -67,7 +66,7 @@ class _ItemFormState extends State { initialValue: widget.isEditing ? widget.item.number.toString() : '1', onChanged: (value) => - _itemFormBloc.add(NumberChanged(number: value)), + _itemFormBloc.add(ItemNumberChanged(number: value)), decoration: InputDecoration( labelText: '数量', ), @@ -98,7 +97,7 @@ class _ItemFormState extends State { )) .toList(), onChanged: (value) { - _itemFormBloc.add(StorageChanged(storage: value)); + _itemFormBloc.add(ItemStorageChanged(storage: value)); }, autovalidate: true, validator: (_) { @@ -109,7 +108,7 @@ class _ItemFormState extends State { initialValue: widget.isEditing ? widget.item.description : '', onChanged: (value) => _itemFormBloc - .add(DescriptionChanged(description: value)), + .add(ItemDescriptionChanged(description: value)), decoration: InputDecoration( labelText: '备注', ), @@ -127,7 +126,7 @@ class _ItemFormState extends State { initialValue: widget.isEditing ? widget.item.price?.toString() : '', onChanged: (value) => - _itemFormBloc.add(PriceChanged(price: value)), + _itemFormBloc.add(ItemPriceChanged(price: value)), decoration: InputDecoration( labelText: '价格', ), @@ -167,8 +166,8 @@ class _ItemFormState extends State { labelText: '有效期至', ), onChanged: (value) { - _itemFormBloc - .add(ExpirationDateChanged(expirationDate: value)); + _itemFormBloc.add( + ItemExpirationDateChanged(expirationDate: value)); }, ), RaisedButton( @@ -209,20 +208,21 @@ class _ItemFormState extends State { _itemFormBloc = BlocProvider.of(context); _itemFormBloc.add(ItemFormStarted()); if (widget.isEditing) { - _itemFormBloc.add(NameChanged(name: widget.item.name)); - _itemFormBloc.add(NumberChanged(number: widget.item.number.toString())); - _itemFormBloc.add(StorageChanged(storage: widget.item.storage.id)); + _itemFormBloc.add(ItemNameChanged(name: widget.item.name)); _itemFormBloc - .add(PriceChanged(price: widget.item.price?.toString() ?? '')); + .add(ItemNumberChanged(number: widget.item.number.toString())); + _itemFormBloc.add(ItemStorageChanged(storage: widget.item.storage.id)); _itemFormBloc - .add(DescriptionChanged(description: widget.item.description)); + .add(ItemPriceChanged(price: widget.item.price?.toString() ?? '')); + _itemFormBloc + .add(ItemDescriptionChanged(description: widget.item.description)); _itemFormBloc.add( - ExpirationDateChanged(expirationDate: widget.item.expirationDate), + ItemExpirationDateChanged(expirationDate: widget.item.expirationDate), ); } else { - _itemFormBloc.add(NameChanged(name: '')); - _itemFormBloc.add(StorageChanged(storage: widget.storageId)); - _itemFormBloc.add(NumberChanged(number: '1')); + _itemFormBloc.add(ItemNameChanged(name: '')); + _itemFormBloc.add(ItemStorageChanged(storage: widget.storageId)); + _itemFormBloc.add(ItemNumberChanged(number: '1')); } _nameFocusNode = FocusNode(); @@ -239,13 +239,13 @@ class _ItemFormState extends State { void _onSubmitPressed() { if (widget.isEditing) { - _itemFormBloc.add(FormSubmitted( + _itemFormBloc.add(ItemFormSubmitted( isEditing: true, id: widget.item.id, oldStorageId: widget.item.storage.id, )); } else { - _itemFormBloc.add(FormSubmitted(isEditing: false)); + _itemFormBloc.add(ItemFormSubmitted(isEditing: false)); } } } diff --git a/lib/pages/storage/widgets/search_form.dart b/lib/pages/storage/widgets/search_form.dart index 352500d4..1b560574 100644 --- a/lib/pages/storage/widgets/search_form.dart +++ b/lib/pages/storage/widgets/search_form.dart @@ -68,13 +68,13 @@ class _SearchBody extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (BuildContext context, StorageSearchState state) { - if (state is StorageSearchLoading) { + if (state is StorageSearchInProgress) { return CircularProgressIndicator(); } - if (state is StorageSearchError) { + if (state is StorageSearchFailure) { return Text(state.message); } - if (state is StorageSearchResults) { + if (state is StorageSearchSuccess) { return state.items.isEmpty && state.storages.isEmpty ? Text('无结果') : Expanded( diff --git a/lib/pages/storage/widgets/storage_form.dart b/lib/pages/storage/widgets/storage_form.dart index 44aae0a9..0de34d5e 100644 --- a/lib/pages/storage/widgets/storage_form.dart +++ b/lib/pages/storage/widgets/storage_form.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:smart_home/blocs/storage/storage_edit/storage_edit_bloc.dart'; -import 'package:smart_home/blocs/storage/storage_form/storage_form_bloc.dart'; +import 'package:smart_home/blocs/storage/blocs.dart'; import 'package:smart_home/models/models.dart'; class StorageForm extends StatefulWidget { @@ -32,13 +31,14 @@ class _StorageFormFormState extends State { _storageFormBloc = BlocProvider.of(context); _storageFormBloc.add(StorageFormStarted()); if (widget.isEditing) { - _storageFormBloc.add(NameChanged(name: widget.storage.name)); - _storageFormBloc.add(ParentChanged(parent: widget.storage.parent?.id)); + _storageFormBloc.add(StorageNameChanged(name: widget.storage.name)); _storageFormBloc - .add(DescriptionChanged(description: widget.storage.description)); + .add(StorageParentChanged(parent: widget.storage.parent?.id)); + _storageFormBloc.add( + StorageDescriptionChanged(description: widget.storage.description)); } else { - _storageFormBloc.add(NameChanged(name: '')); - _storageFormBloc.add(ParentChanged(parent: widget.storageId)); + _storageFormBloc.add(StorageNameChanged(name: '')); + _storageFormBloc.add(StorageParentChanged(parent: widget.storageId)); } _nameFocusNode = FocusNode(); @@ -62,13 +62,13 @@ class _StorageFormFormState extends State { void _onSubmitPressed() { if (widget.isEditing) { - _storageFormBloc.add(FormSubmitted( + _storageFormBloc.add(StorageFormSubmitted( isEditing: true, id: widget.storage.id, oldParentId: widget.storage.parent?.id, )); } else { - _storageFormBloc.add(FormSubmitted(isEditing: false)); + _storageFormBloc.add(StorageFormSubmitted(isEditing: false)); } } @@ -85,7 +85,7 @@ class _StorageFormFormState extends State { TextFormField( initialValue: widget.isEditing ? widget.storage.name : '', onChanged: (value) => - _storageFormBloc.add(NameChanged(name: value)), + _storageFormBloc.add(StorageNameChanged(name: value)), decoration: InputDecoration( labelText: '名称', ), @@ -115,14 +115,14 @@ class _StorageFormFormState extends State { )) .toList(), onChanged: (value) { - _storageFormBloc.add(ParentChanged(parent: value)); + _storageFormBloc.add(StorageParentChanged(parent: value)); }, ), TextFormField( initialValue: widget.isEditing ? widget.storage.description : '', onChanged: (value) => _storageFormBloc - .add(DescriptionChanged(description: value)), + .add(StorageDescriptionChanged(description: value)), decoration: InputDecoration( labelText: '备注', ), diff --git a/lib/pages/storage/widgets/storage_item_list.dart b/lib/pages/storage/widgets/storage_item_list.dart index ad91dbb8..a4d7a5d3 100644 --- a/lib/pages/storage/widgets/storage_item_list.dart +++ b/lib/pages/storage/widgets/storage_item_list.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:smart_home/blocs/storage/blocs.dart'; -import 'package:smart_home/blocs/storage/storage_detail/storage_detail_bloc.dart'; import 'package:smart_home/models/models.dart'; import 'package:smart_home/pages/storage/item_datail_page.dart'; import 'package:smart_home/pages/storage/storage_datail_page.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 6ae96827..056c2fd9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,7 +41,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.2 + cupertino_icons: ^0.1.3 dev_dependencies: flutter_test: diff --git a/web/index.html b/web/index.html index c4e70b70..2b3cc0b4 100644 --- a/web/index.html +++ b/web/index.html @@ -8,7 +8,7 @@ - + diff --git a/web/manifest.json b/web/manifest.json index 15777a5b..917d5e13 100644 --- a/web/manifest.json +++ b/web/manifest.json @@ -2,10 +2,10 @@ "name": "智慧家庭", "short_name": "智慧家庭", "start_url": ".", - "display": "minimal-ui", + "display": "standalone", "background_color": "#0175C2", "theme_color": "#0175C2", - "description": "A new Flutter project.", + "description": "一个管理家庭的网站", "orientation": "portrait-primary", "prefer_related_applications": false, "icons": [