Commit 608c05b4bcc02939f2f9f3fb54883074fa7adbe5

Authored by liangchengyou
1 parent 49e626e9

feat:兑换课程

assets/images/check_lesson_back.png 0 → 100644

59 KB

assets/images/check_steve.png 0 → 100644

74.7 KB

assets/images/check_yellow.png 0 → 100644

12.6 KB

lib/pages/home/home_page.dart
@@ -38,9 +38,8 @@ class _HomePageView extends StatelessWidget { @@ -38,9 +38,8 @@ class _HomePageView extends StatelessWidget {
38 Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop); 38 Navigator.of(AppRouter.context).pushNamed(AppRouteName.shop);
39 } else if (type == HeaderActionType.user) { 39 } else if (type == HeaderActionType.user) {
40 Navigator.of(AppRouter.context).pushNamed(AppRouteName.user); 40 Navigator.of(AppRouter.context).pushNamed(AppRouteName.user);
41 - // Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicPic);  
42 } else { 41 } else {
43 - // Navigator.of(AppRouter.context).pushNamed(AppRouteName.topicPic); 42 +
44 } 43 }
45 } 44 }
46 45
@@ -91,7 +90,14 @@ class _HomePageView extends StatelessWidget { @@ -91,7 +90,14 @@ class _HomePageView extends StatelessWidget {
91 if (data!.lock!) { 90 if (data!.lock!) {
92 return; 91 return;
93 } 92 }
94 - showToast('点击事件'); 93 + if (data!.courseType == 4) {//绘本
  94 + return;
  95 + }
  96 +
  97 + if (data.courseType == 3) {//练习
  98 + Navigator.of(context).pushNamed(AppRouteName.topicPic,arguments: {'courseLessonId':data!.id});
  99 + return;
  100 + }
95 }, 101 },
96 child: HomeVideoItem( 102 child: HomeVideoItem(
97 lessons: data, 103 lessons: data,
lib/pages/practice/bloc/topic_picture_bloc.dart
@@ -16,7 +16,7 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { @@ -16,7 +16,7 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> {
16 16
17 final PageController pageController; 17 final PageController pageController;
18 18
19 - final int modelCount; 19 + final String courseLessonId;
20 20
21 int _currentPage = 0; 21 int _currentPage = 0;
22 22
@@ -39,7 +39,7 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> { @@ -39,7 +39,7 @@ class TopicPictureBloc extends Bloc<TopicPictureEvent, TopicPictureState> {
39 39
40 late AudioPlayer audioPlayer; 40 late AudioPlayer audioPlayer;
41 41
42 - TopicPictureBloc(this.pageController, this.modelCount) : super(TopicPictureInitial()) { 42 + TopicPictureBloc(this.pageController, this.courseLessonId) : super(TopicPictureInitial()) {
43 on<CurrentPageIndexChangeEvent>(_pageControllerChange); 43 on<CurrentPageIndexChangeEvent>(_pageControllerChange);
44 on<SelectItemEvent>(_selectItemLoad); 44 on<SelectItemEvent>(_selectItemLoad);
45 on<RequestDataEvent>(_requestData); 45 on<RequestDataEvent>(_requestData);
@@ -98,7 +98,7 @@ class TopicPictureBloc extends Bloc&lt;TopicPictureEvent, TopicPictureState&gt; { @@ -98,7 +98,7 @@ class TopicPictureBloc extends Bloc&lt;TopicPictureEvent, TopicPictureState&gt; {
98 void _requestData(RequestDataEvent event,Emitter<TopicPictureState> emitter) async { 98 void _requestData(RequestDataEvent event,Emitter<TopicPictureState> emitter) async {
99 try { 99 try {
100 await loading(() async { 100 await loading(() async {
101 - _entity = await ListenDao.process('8'); 101 + _entity = await ListenDao.process(courseLessonId);
102 emitter(RequestDataState()); 102 emitter(RequestDataState());
103 }); 103 });
104 } catch (e) { 104 } catch (e) {
lib/pages/practice/topic_picture_page.dart
@@ -10,14 +10,16 @@ import &#39;bloc/topic_picture_bloc.dart&#39;; @@ -10,14 +10,16 @@ import &#39;bloc/topic_picture_bloc.dart&#39;;
10 import 'widgets/practice_header_widget.dart'; 10 import 'widgets/practice_header_widget.dart';
11 11
12 class TopicPicturePage extends StatelessWidget { 12 class TopicPicturePage extends StatelessWidget {
13 - const TopicPicturePage({super.key}); 13 + const TopicPicturePage({super.key, this.courseLessonId});
  14 +
  15 + final String? courseLessonId;
14 16
15 @override 17 @override
16 Widget build(BuildContext context) { 18 Widget build(BuildContext context) {
17 return BlocProvider( 19 return BlocProvider(
18 create: (context) => TopicPictureBloc( 20 create: (context) => TopicPictureBloc(
19 - PageController(),  
20 - 3 21 + PageController(),
  22 + courseLessonId??'',
21 ) 23 )
22 ..add(RequestDataEvent()) 24 ..add(RequestDataEvent())
23 ..add(XSVoiceInitEvent( 25 ..add(XSVoiceInitEvent(
@@ -38,7 +40,7 @@ class _TopicPicturePage extends StatelessWidget { @@ -38,7 +40,7 @@ class _TopicPicturePage extends StatelessWidget {
38 return BlocListener<TopicPictureBloc,TopicPictureState>( 40 return BlocListener<TopicPictureBloc,TopicPictureState>(
39 listener: (context, state){ 41 listener: (context, state){
40 if (state is RequestDataState) { 42 if (state is RequestDataState) {
41 - // context.read<TopicPictureBloc>().add(CurrentPageIndexChangeEvent(0)); 43 + context.read<TopicPictureBloc>().add(CurrentPageIndexChangeEvent(0));
42 } 44 }
43 45
44 if (state is XSVoiceTestState) { 46 if (state is XSVoiceTestState) {
lib/pages/shop/exchane/exchange_lesson_page.dart
@@ -3,6 +3,7 @@ import &#39;package:flutter_bloc/flutter_bloc.dart&#39;; @@ -3,6 +3,7 @@ import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;
3 import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 import 'package:flutter_screenutil/flutter_screenutil.dart';
4 import 'package:wow_english/common/extension/string_extension.dart'; 4 import 'package:wow_english/common/extension/string_extension.dart';
5 import 'package:wow_english/common/widgets/textfield_customer_widget.dart'; 5 import 'package:wow_english/common/widgets/textfield_customer_widget.dart';
  6 +import 'package:wow_english/pages/shop/exchane/widegts/exchange_result_dialog.dart';
6 import 'package:wow_english/route/route.dart'; 7 import 'package:wow_english/route/route.dart';
7 import 'package:wow_english/utils/toast_util.dart'; 8 import 'package:wow_english/utils/toast_util.dart';
8 9
@@ -26,9 +27,17 @@ class _ExchangeLessonPage extends StatelessWidget { @@ -26,9 +27,17 @@ class _ExchangeLessonPage extends StatelessWidget {
26 return BlocListener<ExchangeLessonBloc, ExchangeLessonState>( 27 return BlocListener<ExchangeLessonBloc, ExchangeLessonState>(
27 listener: (context, state) { 28 listener: (context, state) {
28 if (state is CheckCodeResultState) { 29 if (state is CheckCodeResultState) {
29 - String title = state.result ? '兑换成功' : '兑换失败';  
30 - showToast(title);  
31 - Navigator.of(context).pushNamed(AppRouteName.exList); 30 + showDialog<ExChangeResultDialog>(
  31 + context: context,
  32 + barrierDismissible: !state.result,
  33 + builder: (context){
  34 + return ExChangeResultDialog(
  35 + resultType:state.result,
  36 + onTap:(){
  37 +
  38 + }
  39 + );
  40 + });
32 } 41 }
33 }, 42 },
34 child: _exchangeLessonPageView(), 43 child: _exchangeLessonPageView(),
lib/pages/shop/exchane/widegts/exchange_result_dialog.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 +
  5 +class ExChangeResultDialog extends Dialog {
  6 + const ExChangeResultDialog({super.key,required this.resultType,required this.onTap});
  7 + final bool resultType;
  8 + final Function() onTap;
  9 + @override
  10 + Widget build(BuildContext context) {
  11 + super.build(context);
  12 + return Container(
  13 + alignment: Alignment.center,
  14 + child: Container(
  15 + height: 173.h,
  16 + width: 252.w,
  17 + decoration: BoxDecoration(
  18 + image: DecorationImage(
  19 + image: AssetImage('check_lesson_back'.assetPng),
  20 + fit: BoxFit.fill
  21 + ),
  22 + ),
  23 + child: resultType?_successWidget(context):_failWidget()
  24 + ),
  25 + );
  26 + }
  27 +
  28 + Widget _successWidget(BuildContext context) {
  29 + return Column(
  30 + children: [
  31 + 14.verticalSpace,
  32 + Image.asset(
  33 + 'check_steve'.assetPng,
  34 + width: 69.w,
  35 + height: 88.h,
  36 + ),
  37 + Text(
  38 + '兑换成功',
  39 + style: TextStyle(
  40 + fontSize: 14.sp,
  41 + color: const Color(0xFF333333)
  42 + ),),
  43 + 10.verticalSpace,
  44 + GestureDetector(
  45 + onTap: () {
  46 + Navigator.pop(context);
  47 + onTap();
  48 + },
  49 + child: Container(
  50 + height: 25.h,
  51 + width: 100.w,
  52 + decoration: BoxDecoration(
  53 + image: DecorationImage(
  54 + image: AssetImage('check_yellow'.assetPng),
  55 + fit: BoxFit.fill
  56 + )
  57 + ),
  58 + alignment: Alignment.center,
  59 + child: Text(
  60 + '前往学习',
  61 + textAlign: TextAlign.center,
  62 + style: TextStyle(
  63 + fontSize: 14.sp,
  64 + color: Colors.white
  65 + ),),
  66 + ),
  67 + )
  68 + ],
  69 + );
  70 + }
  71 +
  72 + Widget _failWidget() {
  73 + return Column(
  74 + mainAxisAlignment: MainAxisAlignment.spaceAround,
  75 + children: [
  76 + Image.asset(
  77 + 'steven_bride'.assetPng,
  78 + height: 82.h,
  79 + width: 75.w,
  80 + ),
  81 + Text(
  82 + '兑换失败,请查看兑换码是否正确或兑换码是否在有效期内',
  83 + textAlign: TextAlign.center,
  84 + style: TextStyle(
  85 + color: const Color(0xFF333333),
  86 + fontSize: 14.sp
  87 + ),
  88 + )
  89 + ],
  90 + );
  91 + }
  92 +
  93 +}
0 \ No newline at end of file 94 \ No newline at end of file
lib/pages/user/user_page.dart
@@ -74,7 +74,7 @@ class _UserView extends StatelessWidget { @@ -74,7 +74,7 @@ class _UserView extends StatelessWidget {
74 children: [ 74 children: [
75 CircleAvatar( 75 CircleAvatar(
76 radius: 40.r, 76 radius: 40.r,
77 - backgroundColor: Color(0xFF140C10), 77 + backgroundColor: const Color(0xFF140C10),
78 child: CircleAvatar( 78 child: CircleAvatar(
79 radius: 38.5.r, 79 radius: 38.5.r,
80 backgroundImage: ImageUtil.getImageProviderOnDefault(user.avatarUrl), 80 backgroundImage: ImageUtil.getImageProviderOnDefault(user.avatarUrl),
@@ -151,7 +151,7 @@ class _UserView extends StatelessWidget { @@ -151,7 +151,7 @@ class _UserView extends StatelessWidget {
151 ), 151 ),
152 12.verticalSpace, 152 12.verticalSpace,
153 OutlinedButton( 153 OutlinedButton(
154 - onPressed: () => {}, 154 + onPressed: () => Navigator.of(context).pushNamed(AppRouteName.exLesson),
155 style: normalButtonStyle, 155 style: normalButtonStyle,
156 child: Text( 156 child: Text(
157 "兑换课程", 157 "兑换课程",
lib/route/route.dart
@@ -36,12 +36,6 @@ class AppRouteName { @@ -36,12 +36,6 @@ class AppRouteName {
36 static const String exList = 'exList'; 36 static const String exList = 'exList';
37 static const String reAfter = 'reAfter'; 37 static const String reAfter = 'reAfter';
38 static const String topicPic = 'topicPic'; 38 static const String topicPic = 'topicPic';
39 - static const String topicWord = 'topicWord';  
40 - static const String voicePic = 'voicePic';  
41 - static const String voiceWord = 'voiceWord';  
42 - static const String voiceAnswer = 'voiceAnswer';  
43 -  
44 - /// 用户个人主页  
45 static const String user = 'user'; 39 static const String user = 'user';
46 40
47 /// 用户详细信息页 41 /// 用户详细信息页
@@ -97,7 +91,11 @@ class AppRouter { @@ -97,7 +91,11 @@ class AppRouter {
97 case AppRouteName.userInformation: 91 case AppRouteName.userInformation:
98 return CupertinoPageRoute(builder: (_) => const UserInformationPage()); 92 return CupertinoPageRoute(builder: (_) => const UserInformationPage());
99 case AppRouteName.topicPic: 93 case AppRouteName.topicPic:
100 - return CupertinoPageRoute(builder: (_) => const TopicPicturePage()); 94 + var courseLessonId = '';
  95 + if (settings.arguments != null) {
  96 + courseLessonId = (settings.arguments as Map)['courseLessonId'] as String??'';
  97 + }
  98 + return CupertinoPageRoute(builder: (_) => TopicPicturePage(courseLessonId: courseLessonId));
101 case AppRouteName.lookVideo: 99 case AppRouteName.lookVideo:
102 final videoUrl = (settings.arguments as Map)['videoUrl'] as String; 100 final videoUrl = (settings.arguments as Map)['videoUrl'] as String;
103 final title = (settings.arguments as Map)['title'] as String?; 101 final title = (settings.arguments as Map)['title'] as String?;