Commit 08a0f5a8d40e5fc98111857b64f62efb4d149995

Authored by liangchengyou
1 parent 3c1d5c64

feat:路由方式更新

ios/Runner.xcodeproj/project.pbxproj
... ... @@ -54,6 +54,7 @@
54 54 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
55 55 48BCA0827DCB98991774F5AC /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
56 56 52450AF02A4C415B007B3E4B /* XSMessageMehtodChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XSMessageMehtodChannel.swift; sourceTree = "<group>"; };
  57 + 52450AF22A4ED0EC007B3E4B /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
57 58 525E17192A4BD03900104CDF /* VoiceXSMessageChannel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceXSMessageChannel.swift; sourceTree = "<group>"; };
58 59 6DEBBC1D861BE053F3ECE0B9 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
59 60 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
... ... @@ -147,6 +148,7 @@
147 148 97C146F01CF9000F007C117D /* Runner */ = {
148 149 isa = PBXGroup;
149 150 children = (
  151 + 52450AF22A4ED0EC007B3E4B /* Runner.entitlements */,
150 152 97C146FA1CF9000F007C117D /* Main.storyboard */,
151 153 97C146FD1CF9000F007C117D /* Assets.xcassets */,
152 154 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
... ... @@ -492,6 +494,7 @@
492 494 buildSettings = {
493 495 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
494 496 CLANG_ENABLE_MODULES = YES;
  497 + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
495 498 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
496 499 DEVELOPMENT_TEAM = T8P9KW8GWH;
497 500 ENABLE_BITCODE = NO;
... ... @@ -671,6 +674,7 @@
671 674 buildSettings = {
672 675 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
673 676 CLANG_ENABLE_MODULES = YES;
  677 + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
674 678 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
675 679 DEVELOPMENT_TEAM = T8P9KW8GWH;
676 680 ENABLE_BITCODE = NO;
... ... @@ -694,6 +698,7 @@
694 698 buildSettings = {
695 699 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
696 700 CLANG_ENABLE_MODULES = YES;
  701 + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
697 702 CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
698 703 DEVELOPMENT_TEAM = T8P9KW8GWH;
699 704 ENABLE_BITCODE = NO;
... ...
ios/Runner/Runner.entitlements 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3 +<plist version="1.0">
  4 +<dict>
  5 + <key>aps-environment</key>
  6 + <string>development</string>
  7 +</dict>
  8 +</plist>
... ...
lib/app/splash_page.dart
... ... @@ -36,9 +36,9 @@ class _TransitionViewState extends State&lt;TransitionView&gt; {
36 36 Timer(const Duration(seconds: 2), () {
37 37 if (userEntity != null) {
38 38 // todo 调一下接口判断一下有效性再往下
39   - Navigator.of(context).pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
  39 + pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
40 40 } else {
41   - Navigator.of(context).pushNamedAndRemoveUntil(AppRouteName.login, (route) => false);
  41 + pushNamedAndRemoveUntil(AppRouteName.login, (route) => false);
42 42 }
43 43 });
44 44 }
... ...
lib/pages/home/home_page.dart
... ... @@ -29,15 +29,15 @@ class HomePage extends StatelessWidget {
29 29 class _HomePageView extends StatelessWidget {
30 30 void _headerActionEvent(HeaderActionType type) {
31 31 if (type == HeaderActionType.video) {
32   - Navigator.of(AppRouter.context).pushNamed(AppRouteName.reAfter);
  32 + pushNamed(AppRouteName.reAfter);
33 33 } else if (type == HeaderActionType.phase) {
34   - Navigator.of(AppRouter.context).pushNamed(AppRouteName.lesson);
  34 + pushNamed(AppRouteName.lesson);
35 35 } else if (type == HeaderActionType.listen) {
36   - Navigator.of(AppRouter.context).pushNamed(AppRouteName.listen);
  36 + pushNamed(AppRouteName.listen);
37 37 } else if (type == HeaderActionType.shop) {
38   - Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop);
  38 + pushNamed(AppRouteName.shop);
39 39 } else if (type == HeaderActionType.user) {
40   - Navigator.of(AppRouter.context).pushNamed(AppRouteName.user);
  40 + pushNamed(AppRouteName.user);
41 41 } else {
42 42  
43 43 }
... ... @@ -66,7 +66,7 @@ class _HomePageView extends StatelessWidget {
66 66 if (videoUrl.isEmpty) {
67 67 return;
68 68 }
69   - Navigator.of(context).pushNamed(AppRouteName.lookVideo,arguments: {'videoUrl':videoUrl,'title':title});
  69 + pushNamed(AppRouteName.lookVideo,arguments: {'videoUrl':videoUrl,'title':title});
70 70 }
71 71 },
72 72 child: _homeView(),
... ... @@ -74,100 +74,100 @@ class _HomePageView extends StatelessWidget {
74 74 }
75 75  
76 76 Widget _homeView() => BlocBuilder<HomeBloc, HomeState>(builder: (context, state) {
77   - final bloc = BlocProvider.of<HomeBloc>(context);
78   - return Scaffold(
79   - body: Container(
80   - color: Colors.white,
81   - child: Center(
82   - child: Column(
83   - mainAxisAlignment: MainAxisAlignment.spaceBetween,
84   - children: [
85   - HomeTabHeaderWidget(
86   - actionTap: (HeaderActionType type) {
87   - _headerActionEvent(type);
88   - },
89   - ),
90   - Expanded(
91   - child: ListView.builder(
92   - itemCount: bloc.modelData?.totalCourseLesson,
93   - scrollDirection: Axis.horizontal,
94   - itemBuilder: (BuildContext context, int index) {
95   - CourseCourseLessons? data = bloc.modelData?.courseLessons?[index];
96   - if (data?.courseType == 5) {
97   - //彩蛋
98   - return GestureDetector(
99   - onTap: () {
100   - if (data!.lock!) {
101   - showToast('当前课程暂未解锁');
102   - return;
103   - }
104   - bloc.add(RequestVideoLessonEvent(data.id!,data.courseType!));
105   - },
106   - child: HomeBoundsItem(
107   - imageUrl: data?.coverUrl,
108   - ),
109   - );
110   - } else {
111   - return GestureDetector(
112   - onTap: () {
113   - debugPrint('>>>>>>>类型${data?.courseType}');
114   - if (data!.lock!) {
115   - showToast('当前课程暂未解锁');
116   - return;
117   - }
118   - if (data.courseType == 4) {//绘本
119   - return;
120   - }
  77 + final bloc = BlocProvider.of<HomeBloc>(context);
  78 + return Scaffold(
  79 + body: Container(
  80 + color: Colors.white,
  81 + child: Center(
  82 + child: Column(
  83 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  84 + children: [
  85 + HomeTabHeaderWidget(
  86 + actionTap: (HeaderActionType type) {
  87 + _headerActionEvent(type);
  88 + },
  89 + ),
  90 + Expanded(
  91 + child: ListView.builder(
  92 + itemCount: bloc.modelData?.totalCourseLesson,
  93 + scrollDirection: Axis.horizontal,
  94 + itemBuilder: (BuildContext context, int index) {
  95 + CourseCourseLessons? data = bloc.modelData?.courseLessons?[index];
  96 + if (data?.courseType == 5) {
  97 + //彩蛋
  98 + return GestureDetector(
  99 + onTap: () {
  100 + if (data!.lock!) {
  101 + showToast('当前课程暂未解锁');
  102 + return;
  103 + }
  104 + bloc.add(RequestVideoLessonEvent(data.id!,data.courseType!));
  105 + },
  106 + child: HomeBoundsItem(
  107 + imageUrl: data?.coverUrl,
  108 + ),
  109 + );
  110 + } else {
  111 + return GestureDetector(
  112 + onTap: () {
  113 + debugPrint('>>>>>>>类型${data?.courseType}');
  114 + if (data!.lock!) {
  115 + showToast('当前课程暂未解锁');
  116 + return;
  117 + }
  118 + if (data.courseType == 4) {//绘本
  119 + return;
  120 + }
121 121  
122   - if (data.courseType == 3) {//练习
123   - Navigator.of(context).pushNamed(AppRouteName.topicPic,arguments: {'courseLessonId':data.id!});
124   - return;
125   - }
  122 + if (data.courseType == 3) {//练习
  123 + Navigator.of(context).pushNamed(AppRouteName.topicPic,arguments: {'courseLessonId':data.id!});
  124 + return;
  125 + }
126 126  
127   - //儿歌/看视频
128   - bloc.add(RequestVideoLessonEvent(data.id!,data.courseType!));
129   - },
130   - child: HomeVideoItem(
131   - lessons: data,
132   - ),
133   - );
134   - }
135   - })),
136   - SafeArea(
137   - child: Padding(
138   - padding: EdgeInsets.symmetric(horizontal: 13.w),
139   - child: Row(
140   - mainAxisAlignment: MainAxisAlignment.spaceBetween,
141   - children: [
142   - SizedBox(
143   - height: 47.h,
144   - width: 80.w,
145   - ),
146   - Container(
147   - decoration: BoxDecoration(
148   - color: Colors.blue,
149   - borderRadius: BorderRadius.circular(14.5.r),
150   - ),
151   - padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 24.w),
152   - child: Text(
153   - '${(bloc.modelData?.nowCourseLesson)}/${bloc.modelData?.totalCourseLesson}',
154   - style: TextStyle(color: Colors.white, fontSize: 12.sp),
  127 + //儿歌/看视频
  128 + bloc.add(RequestVideoLessonEvent(data.id!,data.courseType!));
  129 + },
  130 + child: HomeVideoItem(
  131 + lessons: data,
155 132 ),
156   - ),
157   - Image.asset(
158   - 'blue-positive'.assetPng,
159   - height: 47.h,
160   - width: 80.w,
161   - // color: Colors.red,
162   - ),
163   - ],
  133 + );
  134 + }
  135 + })),
  136 + SafeArea(
  137 + child: Padding(
  138 + padding: EdgeInsets.symmetric(horizontal: 13.w),
  139 + child: Row(
  140 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  141 + children: [
  142 + SizedBox(
  143 + height: 47.h,
  144 + width: 80.w,
164 145 ),
165   - ),
166   - )
167   - ],
168   - ),
169   - ),
  146 + Container(
  147 + decoration: BoxDecoration(
  148 + color: Colors.blue,
  149 + borderRadius: BorderRadius.circular(14.5.r),
  150 + ),
  151 + padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 24.w),
  152 + child: Text(
  153 + '${(bloc.modelData?.nowCourseLesson)}/${bloc.modelData?.totalCourseLesson}',
  154 + style: TextStyle(color: Colors.white, fontSize: 12.sp),
  155 + ),
  156 + ),
  157 + Image.asset(
  158 + 'blue-positive'.assetPng,
  159 + height: 47.h,
  160 + width: 80.w,
  161 + // color: Colors.red,
  162 + ),
  163 + ],
  164 + ),
  165 + ),
  166 + )
  167 + ],
170 168 ),
171   - );
172   - });
  169 + ),
  170 + ),
  171 + );
  172 + });
173 173 }
... ...
lib/pages/lessons/lesson_page.dart
... ... @@ -171,7 +171,7 @@ class _LessonPageView extends StatelessWidget {
171 171 model: model,
172 172 isSelected: bloc.currentPageIndex == index,
173 173 onClickEvent: () {
174   - Navigator.of(context).pushNamedAndRemoveUntil(AppRouteName.home, (route) => false,arguments: {'moduleId':model?.id});
  174 + pushNamedAndRemoveUntil(AppRouteName.home, (route) => false,arguments: {'moduleId':model?.id});
175 175 },
176 176 ),
177 177 ),
... ...
lib/pages/login/loginpage/login_page.dart
... ... @@ -30,7 +30,7 @@ class _LoginPageView extends StatelessWidget {
30 30 if (state is LoginResultChangeState) {
31 31 // 调试用
32 32 // Navigator.of(context).pushNamed(AppRouteName.home);
33   - Navigator.of(context).pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
  33 + pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
34 34 }
35 35 },
36 36 child: _buildLoginViewWidget(),
... ...
lib/pages/login/setpwd/set_pwd_page.dart
... ... @@ -57,7 +57,7 @@ class _SetPassWordPageView extends StatelessWidget {
57 57 } else {
58 58 showToast('密码修改成功');
59 59 }
60   - Navigator.of(context).pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
  60 + pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
61 61 } else if (state is PasswordSetFailedState) {
62 62 state.message.toast();
63 63 }
... ...
lib/pages/repeatafter/repeat_after_page.dart
... ... @@ -3,7 +3,7 @@ import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;
3 3 import 'package:wow_english/common/widgets/we_app_bar.dart';
4 4 import 'package:wow_english/models/follow_read_entity.dart';
5 5 import 'package:wow_english/pages/repeatafter/widgets/repeat_after_item.dart';
6   -import 'package:wow_english/utils/toast_util.dart';
  6 +import 'package:wow_english/route/route.dart';
7 7  
8 8 import 'bloc/repeat_after_bloc.dart';
9 9  
... ... @@ -24,9 +24,7 @@ class _RepeatAfterPageView extends StatelessWidget {
24 24 Widget build(BuildContext context) {
25 25 return BlocListener<RepeatAfterBloc, RepeatAfterState>(
26 26 listener: (context, state) {
27   - if (state is RequestDataState) {
28   - showToast('网络请求结束');
29   - }
  27 +
30 28 },
31 29 child: _repeatAfterView(),
32 30 );
... ... @@ -49,7 +47,9 @@ class _RepeatAfterPageView extends StatelessWidget {
49 47 itemBuilder: (BuildContext context, int index) {
50 48 FollowReadEntity? entity = bloc.listData[index];
51 49 return RepeatAfterItem(
52   - tapEvent: () {},
  50 + tapEvent: () {
  51 + pushNamed(AppRouteName.readAfterContent);
  52 + },
53 53 entity: entity,
54 54 );
55 55 }),
... ...
lib/pages/repeatafter/widgets/repeat_after_item.dart
... ... @@ -5,11 +5,11 @@ import &#39;package:wow_english/common/widgets/ow_image_widget.dart&#39;;
5 5 import 'package:wow_english/models/follow_read_entity.dart';
6 6  
7 7 class RepeatAfterItem extends StatelessWidget {
8   - const RepeatAfterItem({super.key, required this.tapEvent, this.entity});
  8 + const RepeatAfterItem({super.key, this.tapEvent, this.entity});
9 9  
10 10 final FollowReadEntity? entity;
11 11  
12   - final Function() tapEvent;
  12 + final Function()? tapEvent;
13 13  
14 14 @override
15 15 Widget build(BuildContext context) {
... ... @@ -20,8 +20,8 @@ class RepeatAfterItem extends StatelessWidget {
20 20 child: GestureDetector(
21 21 onTap: (){
22 22 if (entity != null) {
23   - if (entity?.lock??false) {
24   - tapEvent();
  23 + if (!entity!.lock!) {
  24 + tapEvent?.call();
25 25 }
26 26 }
27 27 },
... ...
lib/pages/repeataftercontent/repeat_after_content_page.dart 0 → 100644
  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  3 +import 'package:wow_english/common/extension/string_extension.dart';
  4 +import 'package:wow_english/route/route.dart';
  5 +
  6 +class RepeatAfterContentPage extends StatelessWidget {
  7 + const RepeatAfterContentPage({super.key});
  8 +
  9 + @override
  10 + Widget build(BuildContext context) {
  11 + return Container(
  12 + color: Colors.white,
  13 + child: SafeArea(
  14 + child: Stack(
  15 + children: [
  16 + Positioned(
  17 + top: 13.h,
  18 + child: GestureDetector(
  19 + onTap: () => popPage(),
  20 + child: Image.asset(
  21 + 'back_around'.assetPng,
  22 + height: 40.h,
  23 + width: 40.w,
  24 + ),
  25 + ),
  26 + )
  27 + ],
  28 + ),
  29 + ),
  30 + );
  31 + }
  32 +}
0 33 \ No newline at end of file
... ...
lib/route/route.dart
... ... @@ -10,6 +10,7 @@ import &#39;package:wow_english/pages/login/loginpage/login_page.dart&#39;;
10 10 import 'package:wow_english/pages/login/setpwd/set_pwd_page.dart';
11 11 import 'package:wow_english/pages/practice/topic_picture_page.dart';
12 12 import 'package:wow_english/pages/repeatafter/repeat_after_page.dart';
  13 +import 'package:wow_english/pages/repeataftercontent/repeat_after_content_page.dart';
13 14 import 'package:wow_english/pages/shop/exchane/exchange_lesson_page.dart';
14 15 import 'package:wow_english/pages/shop/exchangelist/exchange_lesson_list_page.dart';
15 16 import 'package:wow_english/pages/shop/home/shop_home_page.dart';
... ... @@ -40,10 +41,14 @@ class AppRouteName {
40 41  
41 42 /// 用户详细信息页
42 43 static const String userInformation = 'userInformation';
  44 + ///看视频
43 45 static const String lookVideo = 'lookVideo';
  46 + ///绘本
44 47 static const String reading = 'reading';
  48 + ///视频跟读详情
  49 + static const String readAfterContent = 'readAfterContent';
  50 +
45 51  
46   - ///绘本
47 52 static const String tab = '/';
48 53 }
49 54  
... ... @@ -123,6 +128,9 @@ class AppRouter {
123 128 urlStr: urlStr,
124 129 webViewTitle: webViewTitle,
125 130 ));
  131 + case AppRouteName.readAfterContent:
  132 + return CupertinoPageRoute(
  133 + builder: (_) => const RepeatAfterContentPage());
126 134 case AppRouteName.tab:
127 135 return PageRouteBuilder(
128 136 opaque: false,
... ... @@ -138,3 +146,16 @@ class AppRouter {
138 146 }
139 147 }
140 148 }
  149 +
  150 +void pushNamed(String routeName, {Object? arguments}) {
  151 + Navigator.of(AppRouter.context).pushNamed(routeName,arguments: arguments);
  152 +}
  153 +
  154 +void pushNamedAndRemoveUntil(String routeName,RoutePredicate predicate, {Object? arguments}) {
  155 + Navigator.of(AppRouter.context).pushNamedAndRemoveUntil(routeName, predicate,arguments: arguments);
  156 +}
  157 +
  158 +void popPage() {
  159 + Navigator.pop(AppRouter.context);
  160 +}
  161 +
... ...