liuyuqi-dellpc 1 year ago
parent
commit
19f7f5b481
45 changed files with 249 additions and 257 deletions
  1. 3 1
      lib/common/BaseArchitectural.dart
  2. 0 1
      lib/common/I18N.dart
  3. 4 1
      lib/common/LocalData.dart
  4. 1 1
      lib/common/components/PopMenus.dart
  5. 1 1
      lib/common/components/UserInfoPopMenuContext.dart
  6. 1 1
      lib/common/components/UserListTile.dart
  7. 6 6
      lib/main.dart
  8. 6 0
      lib/models/config.dart
  9. 1 1
      lib/network/Repository.dart
  10. 154 8
      lib/pages/home_page.dart
  11. 26 23
      lib/pages/splash_page.dart
  12. 0 0
      lib/provider/ConfigProvider.dart
  13. 1 1
      lib/provider/DataProvider.dart
  14. 1 1
      lib/provider/NotificationProvider.dart
  15. 1 1
      lib/provider/ThemeProvider.dart
  16. 1 1
      lib/provider/UserProvider.dart
  17. 2 2
      lib/view/context/BasicInfoContext.dart
  18. 2 2
      lib/view/context/ExerciseInfoContext.dart
  19. 1 1
      lib/view/context/LifeInfoContext.dart
  20. 1 1
      lib/view/context/StudyInfoContext.dart
  21. 1 1
      lib/view/context/widget/DateTimeMultiLineChart.dart
  22. 1 1
      lib/view/context/widget/DateValueMultiLineChart.dart
  23. 1 1
      lib/view/context/widget/StudyInfoDetailsPage.dart
  24. 2 2
      lib/view/drawer/HomePageDrawer.dart
  25. 1 1
      lib/view/drawer/community/FollowedPage.dart
  26. 1 1
      lib/view/drawer/community/RankingListPage.dart
  27. 1 1
      lib/view/drawer/community/SearchUserPage.dart
  28. 2 2
      lib/view/drawer/setting/DataManagementPage.dart
  29. 2 2
      lib/view/drawer/setting/DebugPage.dart
  30. 2 2
      lib/view/drawer/setting/NotificationSetPage.dart
  31. 1 1
      lib/view/drawer/setting/SettingPage.dart
  32. 3 3
      lib/view/drawer/setting/SignTimeSetPage.dart
  33. 2 2
      lib/view/drawer/setting/ThemeSetPage.dart
  34. 1 1
      lib/view/drawer/shop/GoodsPage.dart
  35. 1 1
      lib/view/drawer/shop/ShopPage.dart
  36. 1 1
      lib/view/drawer/user/UserPage.dart
  37. 1 1
      lib/view/drawer/user/setting/UserSettingPage.dart
  38. 1 1
      lib/view/drawer/user/sign/ModifyPwdPage.dart
  39. 1 1
      lib/view/drawer/user/sign/SignInPage.dart
  40. 0 167
      lib/view/home_page.dart
  41. 2 2
      lib/view/record/BasicInfoRecordingPage.dart
  42. 2 2
      lib/view/record/ExerciseInfoRecordingPage.dart
  43. 3 3
      lib/view/record/LifeInfoRecordingPage.dart
  44. 2 2
      lib/view/record/StudyInfoRecordingPage.dart
  45. 1 1
      lib/view/record/sub/AddScheduledExercisePage.dart

+ 3 - 1
lib/common/BaseArchitectural.dart

@@ -4,11 +4,13 @@ import 'package:sqflite/sqflite.dart';
 
 import 'SqfliteDataBase.dart';
 
+
 abstract class BaseProvider extends ChangeNotifier {
+
   BaseProvider(BuildContext context) {
     init(context);
   }
-
+  /// 初始化方法,子类覆写
   void init(BuildContext context) {}
 }
 

+ 0 - 1
lib/common/I18N.dart

@@ -15,7 +15,6 @@ class I18N {
 
   static String of(String key) {
     return wordMap[_language][key] ?? "${_language.toUpperCase()}_$key";
-//    return key.toString();
   }
 
   static String getLanguage() {

+ 4 - 1
lib/common/LocalData.dart

@@ -1,6 +1,9 @@
 import 'package:flutter/material.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 
+/// Description: LocalData
+/// Time       : 08/18/2023 Friday
+/// Author     : liuyuqi.gov@msn.cn
 class LocalData {
   static SharedPreferences _sharedPreferences;
   static init() async {
@@ -13,4 +16,4 @@ class LocalData {
   static SharedPreferences getInstance() {
     return _sharedPreferences;
   }
-}
+}

+ 1 - 1
lib/common/components/PopMenus.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:provider/provider.dart';
 
 import 'SliderConfirm.dart';

+ 1 - 1
lib/common/components/UserInfoPopMenuContext.dart

@@ -2,7 +2,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';
 

+ 1 - 1
lib/common/components/UserListTile.dart

@@ -1,7 +1,7 @@
 
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';
 

+ 6 - 6
lib/main.dart

@@ -1,12 +1,12 @@
 import 'package:flutter/material.dart';
-import 'package:flutter_habit/common/provider/ConfigProvider.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
-import 'package:flutter_habit/view/LoadingPage.dart';
+import 'package:flutter_habit/provider/ConfigProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
+import 'package:flutter_habit/pages/splash_page.dart';
 import 'package:provider/provider.dart';
 
-import 'common/provider/NotificationProvider.dart';
-import 'common/provider/ThemeProvider.dart';
+import 'provider/NotificationProvider.dart';
+import 'provider/ThemeProvider.dart';
 
 void main() {
   runApp(

+ 6 - 0
lib/models/config.dart

@@ -0,0 +1,6 @@
+/// Description: config 
+/// Time       : 08/18/2023 Friday
+/// Author     : liuyuqi.gov@msn.cn
+class Config {
+  
+}

+ 1 - 1
lib/network/Repository.dart

@@ -2,7 +2,7 @@ import 'package:dio/dio.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:provider/provider.dart';
 

+ 154 - 8
lib/pages/home_page.dart

@@ -1,18 +1,164 @@
-import 'package:flutter/src/widgets/framework.dart';
-import 'package:flutter/src/widgets/placeholder.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_habit/common/BaseArchitectural.dart';
+import 'package:flutter_habit/common/I18N.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
+import 'package:flutter_habit/view/context/ExerciseInfoContext.dart';
+import 'package:flutter_habit/view/context/LifeInfoContext.dart';
+import 'package:flutter_habit/view/context/BasicInfoContext.dart';
+import 'package:flutter_habit/view/context/StudyInfoContext.dart';
+import 'package:flutter_habit/view/drawer/HomePageDrawer.dart';
+import 'package:flutter_habit/view/record/BasicInfoRecordingPage.dart';
+import 'package:flutter_habit/view/record/ExerciseInfoRecordingPage.dart';
+import 'package:flutter_habit/view/record/LifeInfoRecordingPage.dart';
+import 'package:flutter_habit/view/record/StudyInfoRecordingPage.dart';
+import 'package:provider/provider.dart';
+
 /// Description: Home Page
 /// Time       : 08/18/2023 Friday
 /// Author     : liuyuqi.gov@msn.cn
-class HomePage extends StatefulWidget {
-  const HomePage({Key key}) : super(key: key);
+class HomePage extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    print("========================homepage。。。。");
+    return MultiProvider(
+      providers: [
+        ChangeNotifierProvider<HomePageService>(
+            create: (_) => HomePageService(context)),
+        ChangeNotifierProvider<HomePageModel>(
+            create: (_) => HomePageModel(context)),
+      ],
+      child: _HomePageView(),
+    );
+  }
+}
+
+// model
+class HomePageModel extends BaseModel {
+  HomePageModel(BuildContext context) : super(context);
+
+  int currentIndex;
+
+  PageController pageViewController;
 
   @override
-  State<HomePage> createState() => _HomePageState();
+  void init(BuildContext context) {
+    super.init(context);
+    currentIndex = 0;
+    pageViewController = PageController(initialPage: 0);
+  }
+}
+
+// service
+class HomePageService extends BaseProvider {
+  HomePageService(BuildContext context) : super(context);
+
+  void changeNavigation(BuildContext context, int index) {
+    HomePageModel model = Provider.of<HomePageModel>(context, listen: false);
+    model.currentIndex = index;
+    model.pageViewController.animateToPage(index,
+        duration: Duration(milliseconds: 300), curve: Curves.ease);
+    model.refresh();
+  }
+
+  void onPageChanged(BuildContext context, int index) {
+    HomePageModel model = Provider.of<HomePageModel>(context, listen: false);
+    model.currentIndex = index;
+    model.refresh();
+  }
+
+  Future<void> toBasicInfoRecordingPage(BuildContext context) async {
+    await Navigator.of(context)
+        .push(MaterialPageRoute(builder: (_) => BasicInfoRecordingPage()));
+  }
+
+  Future<void> toLifeInfoRecordingPage(BuildContext context) async {
+    await Navigator.of(context)
+        .push(MaterialPageRoute(builder: (_) => LifeInfoRecordingPage()));
+  }
+
+  Future<void> toExerciseInfoRecordingPage(BuildContext context) async {
+    await Navigator.of(context)
+        .push(MaterialPageRoute(builder: (_) => ExerciseInfoRecordingPage()));
+  }
+
+  Future<void> toStudyInfoRecordingPage(BuildContext context) async {
+    await Navigator.of(context)
+        .push(MaterialPageRoute(builder: (_) => StudyInfoRecordingPage()));
+  }
 }
 
-class _HomePageState extends State<HomePage> {
+// view
+class _HomePageView extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
-    return const Placeholder();
+    HomePageService service =
+        Provider.of<HomePageService>(context, listen: false);
+    HomePageModel model = Provider.of<HomePageModel>(context, listen: true);
+    UserProvider userProvider =
+        Provider.of<UserProvider>(context, listen: true);
+    return Scaffold(
+      appBar: AppBar(
+        title: Text("Home"),
+        actions: userProvider.token == null
+            ? []
+            : <Widget>[
+                Row(
+                  children: <Widget>[
+                    Text(
+                      "${userProvider.coins} x ",
+                      style: TextStyle(fontSize: 16),
+                    ),
+                    Icon(Icons.monetization_on),
+                    Text("  "),
+                  ],
+                ),
+              ],
+      ),
+      drawer: HomePageDrawer(),
+      body: PageView(
+        controller: model.pageViewController,
+        onPageChanged: (index) => service.onPageChanged(context, index),
+        physics: NeverScrollableScrollPhysics(),
+        children: <Widget>[
+          BasicInfoContext(),
+          LifeInfoContext(),
+          ExerciseInfoContext(),
+          StudyInfoContext(),
+        ],
+      ),
+      floatingActionButton: <Widget>[
+        FloatingActionButton(
+          child: Icon(Icons.playlist_add),
+          onPressed: () => service.toBasicInfoRecordingPage(context),
+        ),
+        FloatingActionButton(
+          child: Icon(Icons.playlist_add),
+          onPressed: () => service.toLifeInfoRecordingPage(context),
+        ),
+        FloatingActionButton(
+          child: Icon(Icons.playlist_add),
+          onPressed: () => service.toExerciseInfoRecordingPage(context),
+        ),
+        FloatingActionButton(
+          child: Icon(Icons.playlist_add),
+          onPressed: () => service.toStudyInfoRecordingPage(context),
+        ),
+      ][model.currentIndex],
+      bottomNavigationBar: BottomNavigationBar(
+        currentIndex: model.currentIndex,
+        onTap: (index) => service.changeNavigation(context, index),
+        showUnselectedLabels: true,
+        fixedColor: Theme.of(context).colorScheme.secondary,
+        unselectedItemColor: Theme.of(context).unselectedWidgetColor,
+        items: <BottomNavigationBarItem>[
+          BottomNavigationBarItem(
+              icon: Icon(Icons.accessibility), label: "基本信息"),
+          BottomNavigationBarItem(icon: Icon(Icons.wb_sunny), label: "日常生活"),
+          BottomNavigationBarItem(
+              icon: Icon(Icons.directions_bike), label: "体育锻炼"),
+          BottomNavigationBarItem(icon: Icon(Icons.school), label: "课程学习"),
+        ],
+      ),
+    );
   }
-}
+}

+ 26 - 23
lib/view/LoadingPage.dart → lib/pages/splash_page.dart

@@ -5,15 +5,15 @@ import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/LocalData.dart';
 import 'package:flutter_habit/common/SqfliteDataBase.dart';
-import 'package:flutter_habit/common/provider/ConfigProvider.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/NotificationProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
-import 'package:flutter_habit/common/provider/ThemeProvider.dart';
-import 'package:flutter_habit/view/home_page.dart';
+import 'package:flutter_habit/provider/ConfigProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/NotificationProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/ThemeProvider.dart';
+import 'package:flutter_habit/pages/home_page.dart';
 import 'package:provider/provider.dart';
 
-/// Description:
+/// Description: Spalsh Page
 /// Time       : 08/17/2023 Thursday
 /// Author     : liuyuqi.gov@msn.cn
 class LoadingPage extends StatelessWidget {
@@ -21,8 +21,8 @@ class LoadingPage extends StatelessWidget {
   Widget build(BuildContext context) {
     return MultiProvider(
       providers: [
-        ChangeNotifierProvider<LoadingPageService>(
-            create: (_) => LoadingPageService(context)),
+        ChangeNotifierProvider<SplashPageProvider>(
+            create: (_) => SplashPageProvider(context)),
       ],
       child: _LoadingPageView(),
     );
@@ -30,11 +30,10 @@ class LoadingPage extends StatelessWidget {
 }
 
 // service
-class LoadingPageService extends BaseProvider {
-  LoadingPageService(BuildContext context) : super(context);
+class SplashPageProvider extends BaseProvider {
+  SplashPageProvider(BuildContext context) : super(context);
 
   Timer timer;
-
   bool isLoaded;
 
   Future<void> loadData(BuildContext context) async {
@@ -57,6 +56,7 @@ class LoadingPageService extends BaseProvider {
 
   @override
   void init(BuildContext context) {
+    print("---------init-------------spalsh-------------provider");
     super.init(context);
     isLoaded = false;
     timer = null;
@@ -65,19 +65,21 @@ class LoadingPageService extends BaseProvider {
   }
 
   void startCountDown(BuildContext context) {
-    if (timer == null) {
-      int minDuration = 3;
-      timer = Timer.periodic(Duration(seconds: 1), (t) {
-        minDuration--;
-        if (isLoaded && minDuration <= 0) {
-          timer.cancel();
+    // if (timer == null) {
+    //   int minDuration = 3;
+    //   timer = Timer.periodic(Duration(seconds: 5), (t) {
+    //     minDuration--;
+    //     if (isLoaded && minDuration <= 0) {
+    //       timer.cancel();
           scalaJumpToHomePage(context);
-        }
-      });
-    }
+    //     }
+    //   });
+    // }
   }
 
+  /// 跳转到Home Page
   void scalaJumpToHomePage(BuildContext context) {
+    print("---------go mail page---------");
     Navigator.of(context).pushReplacement(PageRouteBuilder(
         transitionDuration: Duration(milliseconds: 600),
         pageBuilder: (context, animation, secondaryAnimation) =>
@@ -97,8 +99,9 @@ class LoadingPageService extends BaseProvider {
 class _LoadingPageView extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
-    LoadingPageService service =
-        Provider.of<LoadingPageService>(context, listen: false);
+    // SplashPageProvider service =
+    Provider.of<SplashPageProvider>(context, listen: false);
+
     return ConstrainedBox(
       constraints: BoxConstraints.expand(),
       child: Image.asset(

+ 0 - 0
lib/common/provider/ConfigProvider.dart → lib/provider/ConfigProvider.dart


+ 1 - 1
lib/common/provider/DataProvider.dart → lib/provider/DataProvider.dart

@@ -2,7 +2,7 @@ import 'dart:async';
 
 import 'package:fl_chart/fl_chart.dart';
 import 'package:flutter/material.dart';
-import 'package:flutter_habit/common/provider/ConfigProvider.dart';
+import 'package:flutter_habit/provider/ConfigProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/common/utils/VerificationUtils.dart';
 import 'package:flutter_habit/database/entity/BasicInfo.dart';

+ 1 - 1
lib/common/provider/NotificationProvider.dart → lib/provider/NotificationProvider.dart

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_local_notifications/flutter_local_notifications.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/LocalData.dart';
-import 'package:flutter_habit/common/provider/ConfigProvider.dart';
+import 'package:flutter_habit/provider/ConfigProvider.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 
 class NotificationProvider extends ChangeNotifier {

+ 1 - 1
lib/common/provider/ThemeProvider.dart → lib/provider/ThemeProvider.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 
-import '../LocalData.dart';
+import '../common/LocalData.dart';
 
 class ThemeProvider extends ChangeNotifier {
   int currentIndex;

+ 1 - 1
lib/common/provider/UserProvider.dart → lib/provider/UserProvider.dart

@@ -3,7 +3,7 @@ import 'dart:typed_data';
 
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/LocalData.dart';
-import 'package:flutter_habit/view/home_page.dart';
+import 'package:flutter_habit/pages/home_page.dart';
 
 class UserProvider extends ChangeNotifier {
   String token;

+ 2 - 2
lib/view/context/BasicInfoContext.dart

@@ -1,8 +1,8 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/view/context/widget/BaseCard.dart';
 import 'package:flutter_habit/view/context/widget/DateValueMultiLineChart.dart';

+ 2 - 2
lib/view/context/ExerciseInfoContext.dart

@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/database/entity/ExerciseInfo.dart';
 import 'package:flutter_habit/database/entity/ScheduledExercise.dart';

+ 1 - 1
lib/view/context/LifeInfoContext.dart

@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/view/context/widget/BaseCard.dart';
 import 'package:flutter_habit/view/context/widget/DateTimeMultiLineChart.dart';

+ 1 - 1
lib/view/context/StudyInfoContext.dart

@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
 import 'package:flutter_habit/database/entity/StudyInfo.dart';
 import 'package:flutter_habit/view/context/widget/BaseCard.dart';
 import 'package:flutter_habit/view/context/widget/DateValueSingleLineChart.dart';

+ 1 - 1
lib/view/context/widget/DateTimeMultiLineChart.dart

@@ -1,7 +1,7 @@
 import 'package:fl_chart/fl_chart.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/ThemeProvider.dart';
+import 'package:flutter_habit/provider/ThemeProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:provider/provider.dart';
 

+ 1 - 1
lib/view/context/widget/DateValueMultiLineChart.dart

@@ -1,7 +1,7 @@
 import 'package:fl_chart/fl_chart.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/ThemeProvider.dart';
+import 'package:flutter_habit/provider/ThemeProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:provider/provider.dart';
 

+ 1 - 1
lib/view/context/widget/StudyInfoDetailsPage.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
 import 'package:flutter_habit/database/entity/StudyInfo.dart';
 import 'package:flutter_habit/database/mapper/StudyInfoMapper.dart';
 import 'package:provider/provider.dart';

+ 2 - 2
lib/view/drawer/HomePageDrawer.dart

@@ -2,8 +2,8 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/view/drawer/community/FollowedPage.dart';
 import 'package:flutter_habit/view/drawer/community/RankingListPage.dart';
 import 'package:flutter_habit/view/drawer/community/SearchUserPage.dart';

+ 1 - 1
lib/view/drawer/community/FollowedPage.dart

@@ -4,7 +4,7 @@ import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
 import 'package:flutter_habit/common/components/UserListTile.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';
 

+ 1 - 1
lib/view/drawer/community/RankingListPage.dart

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
 import 'package:flutter_habit/common/components/UserListTile.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';
 

+ 1 - 1
lib/view/drawer/community/SearchUserPage.dart

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
 import 'package:flutter_habit/common/components/UserListTile.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/VerificationUtils.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';

+ 2 - 2
lib/view/drawer/setting/DataManagementPage.dart

@@ -7,8 +7,8 @@ import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/SqfliteDataBase.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/database/mapper/BasicInfoMapper.dart';
 import 'package:flutter_habit/database/mapper/ExerciseInfoMapper.dart';
 import 'package:flutter_habit/database/mapper/LifeInfoMapper.dart';

+ 2 - 2
lib/view/drawer/setting/DebugPage.dart

@@ -3,8 +3,8 @@ import 'dart:math';
 import 'package:flutter/material.dart';
 import 'package:flutter_local_notifications/flutter_local_notifications.dart';
 import 'package:flutter_habit/common/SqfliteDataBase.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/NotificationProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/NotificationProvider.dart';
 import 'package:flutter_habit/database/entity/BasicInfo.dart';
 import 'package:flutter_habit/database/entity/ExerciseInfo.dart';
 import 'package:flutter_habit/database/entity/FoodInfo.dart';

+ 2 - 2
lib/view/drawer/setting/NotificationSetPage.dart

@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/ConfigProvider.dart';
-import 'package:flutter_habit/common/provider/NotificationProvider.dart';
+import 'package:flutter_habit/provider/ConfigProvider.dart';
+import 'package:flutter_habit/provider/NotificationProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:provider/provider.dart';
 

+ 1 - 1
lib/view/drawer/setting/SettingPage.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/view/drawer/setting/DataManagementPage.dart';
 import 'package:flutter_habit/view/drawer/setting/DebugPage.dart';
 import 'package:flutter_habit/view/drawer/setting/NotificationSetPage.dart';

+ 3 - 3
lib/view/drawer/setting/SignTimeSetPage.dart

@@ -1,9 +1,9 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/ConfigProvider.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/NotificationProvider.dart';
+import 'package:flutter_habit/provider/ConfigProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/NotificationProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:provider/provider.dart';
 

+ 2 - 2
lib/view/drawer/setting/ThemeSetPage.dart

@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/ThemeProvider.dart';
+import 'package:flutter_habit/provider/ThemeProvider.dart';
 import 'package:provider/provider.dart';
 
 class ThemeSetPage extends StatelessWidget {
@@ -60,7 +60,7 @@ class _ThemeSetPageView extends StatelessWidget {
                     backgroundColor:
                         MaterialStateProperty.all(themeColors[index]),
                   ),
-                  onPressed: () => service.changeThemeTo(context, index),
+                  onPressed: () => service.changeThemeTo(context, index), child: Text(""),
                 ),
               );
             } else if (index == themeColors.length) {

+ 1 - 1
lib/view/drawer/shop/GoodsPage.dart

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_markdown/flutter_markdown.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';
 

+ 1 - 1
lib/view/drawer/shop/ShopPage.dart

@@ -1,6 +1,6 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:flutter_habit/view/drawer/shop/GoodsPage.dart';
 import 'package:provider/provider.dart';

+ 1 - 1
lib/view/drawer/user/UserPage.dart

@@ -2,7 +2,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/view/drawer/user/setting/UserSettingPage.dart';
 import 'package:flutter_habit/view/drawer/user/sign/SignInPage.dart';
 import 'package:provider/provider.dart';

+ 1 - 1
lib/view/drawer/user/setting/UserSettingPage.dart

@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/VerificationUtils.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:flutter_habit/view/drawer/user/setting/CropImagePage.dart';

+ 1 - 1
lib/view/drawer/user/sign/ModifyPwdPage.dart

@@ -3,7 +3,7 @@ import 'dart:async';
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/VerificationUtils.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:provider/provider.dart';

+ 1 - 1
lib/view/drawer/user/sign/SignInPage.dart

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/network/Repository.dart';
 import 'package:flutter_habit/view/drawer/user/sign/ModifyPwdPage.dart';
 import 'package:flutter_habit/view/drawer/user/sign/SignUpPage.dart';

+ 0 - 167
lib/view/home_page.dart

@@ -1,167 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_habit/common/BaseArchitectural.dart';
-import 'package:flutter_habit/common/I18N.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
-import 'package:flutter_habit/view/context/ExerciseInfoContext.dart';
-import 'package:flutter_habit/view/context/LifeInfoContext.dart';
-import 'package:flutter_habit/view/context/BasicInfoContext.dart';
-import 'package:flutter_habit/view/context/StudyInfoContext.dart';
-import 'package:flutter_habit/view/drawer/HomePageDrawer.dart';
-import 'package:flutter_habit/view/record/BasicInfoRecordingPage.dart';
-import 'package:flutter_habit/view/record/ExerciseInfoRecordingPage.dart';
-import 'package:flutter_habit/view/record/LifeInfoRecordingPage.dart';
-import 'package:flutter_habit/view/record/StudyInfoRecordingPage.dart';
-import 'package:provider/provider.dart';
-
-class HomePage extends StatelessWidget {
-  @override
-  Widget build(BuildContext context) {
-    return MultiProvider(
-      providers: [
-        ChangeNotifierProvider<HomePageService>(
-            create: (_) => HomePageService(context)),
-        ChangeNotifierProvider<HomePageModel>(
-            create: (_) => HomePageModel(context)),
-      ],
-      child: _HomePageView(),
-    );
-  }
-}
-
-// model
-class HomePageModel extends BaseModel {
-  HomePageModel(BuildContext context) : super(context);
-
-  int currentIndex;
-
-  PageController pageViewController;
-
-  @override
-  void init(BuildContext context) {
-    super.init(context);
-    currentIndex = 0;
-    pageViewController = PageController(initialPage: 0);
-  }
-}
-
-// service
-class HomePageService extends BaseProvider {
-  HomePageService(BuildContext context) : super(context);
-
-  void changeNavigation(BuildContext context, int index) {
-    HomePageModel model = Provider.of<HomePageModel>(context, listen: false);
-    model.currentIndex = index;
-    model.pageViewController.animateToPage(index,
-        duration: Duration(milliseconds: 300), curve: Curves.ease);
-    model.refresh();
-  }
-
-  void onPageChanged(BuildContext context, int index) {
-    HomePageModel model = Provider.of<HomePageModel>(context, listen: false);
-    model.currentIndex = index;
-    model.refresh();
-  }
-
-  Future<void> toBasicInfoRecordingPage(BuildContext context) async {
-    await Navigator.of(context)
-        .push(MaterialPageRoute(builder: (_) => BasicInfoRecordingPage()));
-  }
-
-  Future<void> toLifeInfoRecordingPage(BuildContext context) async {
-    await Navigator.of(context)
-        .push(MaterialPageRoute(builder: (_) => LifeInfoRecordingPage()));
-  }
-
-  Future<void> toExerciseInfoRecordingPage(BuildContext context) async {
-    await Navigator.of(context)
-        .push(MaterialPageRoute(builder: (_) => ExerciseInfoRecordingPage()));
-  }
-
-  Future<void> toStudyInfoRecordingPage(BuildContext context) async {
-    await Navigator.of(context)
-        .push(MaterialPageRoute(builder: (_) => StudyInfoRecordingPage()));
-  }
-}
-
-// view
-class _HomePageView extends StatelessWidget {
-  @override
-  Widget build(BuildContext context) {
-    HomePageService service =
-        Provider.of<HomePageService>(context, listen: false);
-    HomePageModel model = Provider.of<HomePageModel>(context, listen: true);
-    UserProvider userProvider =
-        Provider.of<UserProvider>(context, listen: true);
-    return Scaffold(
-      appBar: AppBar(
-        title: Text(I18N.of(<String>[
-          "基本信息",
-          "日常生活",
-          "体育锻炼",
-          "课程学习",
-        ][model.currentIndex])),
-        actions: userProvider.token == null
-            ? []
-            : <Widget>[
-                Row(
-                  children: <Widget>[
-                    Text(
-                      "${userProvider.coins} x ",
-                      style: TextStyle(fontSize: 16),
-                    ),
-                    Icon(Icons.monetization_on),
-                    Text("  "),
-                  ],
-                ),
-              ],
-      ),
-      drawer: HomePageDrawer(),
-      body: PageView(
-        controller: model.pageViewController,
-        onPageChanged: (index) => service.onPageChanged(context, index),
-        physics: NeverScrollableScrollPhysics(),
-        children: <Widget>[
-          BasicInfoContext(),
-          LifeInfoContext(),
-          ExerciseInfoContext(),
-          StudyInfoContext(),
-        ],
-      ),
-      floatingActionButton: <Widget>[
-        FloatingActionButton(
-          child: Icon(Icons.playlist_add),
-          onPressed: () => service.toBasicInfoRecordingPage(context),
-        ),
-        FloatingActionButton(
-          child: Icon(Icons.playlist_add),
-          onPressed: () => service.toLifeInfoRecordingPage(context),
-        ),
-        FloatingActionButton(
-          child: Icon(Icons.playlist_add),
-          onPressed: () => service.toExerciseInfoRecordingPage(context),
-        ),
-        FloatingActionButton(
-          child: Icon(Icons.playlist_add),
-          onPressed: () => service.toStudyInfoRecordingPage(context),
-        ),
-      ][model.currentIndex],
-      bottomNavigationBar: BottomNavigationBar(
-        currentIndex: model.currentIndex,
-        onTap: (index) => service.changeNavigation(context, index),
-        showUnselectedLabels: true,
-        fixedColor: Theme.of(context).colorScheme.secondary,
-        unselectedItemColor: Theme.of(context).unselectedWidgetColor,
-        items: <BottomNavigationBarItem>[
-          BottomNavigationBarItem(
-              icon: Icon(Icons.accessibility), label: I18N.of("基本信息")),
-          BottomNavigationBarItem(
-              icon: Icon(Icons.wb_sunny), label: I18N.of("日常生活")),
-          BottomNavigationBarItem(
-              icon: Icon(Icons.directions_bike), label: I18N.of("体育锻炼")),
-          BottomNavigationBarItem(
-              icon: Icon(Icons.school), label: I18N.of("课程学习")),
-        ],
-      ),
-    );
-  }
-}

+ 2 - 2
lib/view/record/BasicInfoRecordingPage.dart

@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/database/entity/BasicInfo.dart';
 import 'package:flutter_habit/database/mapper/BasicInfoMapper.dart';

+ 2 - 2
lib/view/record/ExerciseInfoRecordingPage.dart

@@ -1,8 +1,8 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/database/entity/ExerciseInfo.dart';
 import 'package:flutter_habit/database/entity/SportInfo.dart';

+ 3 - 3
lib/view/record/LifeInfoRecordingPage.dart

@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/ConfigProvider.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/ConfigProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/common/utils/VerificationUtils.dart';
 import 'package:flutter_habit/database/entity/FoodInfo.dart';

+ 2 - 2
lib/view/record/StudyInfoRecordingPage.dart

@@ -3,8 +3,8 @@ import 'package:flutter_markdown/flutter_markdown.dart';
 import 'package:flutter_habit/common/BaseArchitectural.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
-import 'package:flutter_habit/common/provider/UserProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/UserProvider.dart';
 import 'package:flutter_habit/common/utils/ConvertUtils.dart';
 import 'package:flutter_habit/database/entity/StudyInfo.dart';
 import 'package:flutter_habit/database/mapper/StudyInfoMapper.dart';

+ 1 - 1
lib/view/record/sub/AddScheduledExercisePage.dart

@@ -1,7 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_habit/common/I18N.dart';
 import 'package:flutter_habit/common/components/PopMenus.dart';
-import 'package:flutter_habit/common/provider/DataProvider.dart';
+import 'package:flutter_habit/provider/DataProvider.dart';
 import 'package:flutter_habit/database/entity/ScheduledExercise.dart';
 import 'package:flutter_habit/database/entity/SportInfo.dart';
 import 'package:flutter_habit/database/mapper/ScheduledExerciseMapper.dart';