From df1fea3c706ae45e85d34b40c07eaa26536e7a73 Mon Sep 17 00:00:00 2001 From: ljyo2o9 Date: Thu, 11 Jul 2024 13:35:46 +0900 Subject: [PATCH] =?UTF-8?q?FEAT=20::=20home=5Ftoday=5Froutine=5Fbutton?= =?UTF-8?q?=EC=97=90=20routineStartScreen=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/home_today_routine_screen.dart | 1 + .../home_today_routine_button.dart | 119 +++++++++++------- 2 files changed, 75 insertions(+), 45 deletions(-) diff --git a/lib/home/presentation/view/home_today_routine_screen.dart b/lib/home/presentation/view/home_today_routine_screen.dart index eeb41aeb..3456ffe5 100644 --- a/lib/home/presentation/view/home_today_routine_screen.dart +++ b/lib/home/presentation/view/home_today_routine_screen.dart @@ -121,6 +121,7 @@ class HomeTodayRoutineScreen extends ConsumerWidget { bottomSheet: HomeTodayRoutineButton( isCompleted: todayRoutine.isCompleted!, routineId: todayRoutine.id!, + routineList: todayRoutine.exerciseInfoResponseList!, ), ); } diff --git a/lib/home/presentation/widget/today_routine/home_today_routine_button.dart b/lib/home/presentation/widget/today_routine/home_today_routine_button.dart index 4b120268..8ec58716 100644 --- a/lib/home/presentation/widget/today_routine/home_today_routine_button.dart +++ b/lib/home/presentation/widget/today_routine/home_today_routine_button.dart @@ -1,62 +1,91 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:maeum_ga_gym_flutter/home/presentation/providers/home_today_routines_provider.dart'; +import 'package:maeum_ga_gym_flutter/core/component/image/images.dart'; +import 'package:maeum_ga_gym_flutter/core/component/image_widget.dart'; +import 'package:maeum_ga_gym_flutter/routine_start/presentation/provider/routine_start_page_view_provider.dart'; +import 'package:maeum_ga_gym_flutter/routine_start/presentation/view/routine_start_main_screen.dart'; import '../../../../config/maeumgagym_color.dart'; import '../../../../core/component/text/pretendard/ptd_text_widget.dart'; +import '../../../domain/model/home_today_routines_model.dart'; class HomeTodayRoutineButton extends ConsumerWidget { final int routineId; final bool isCompleted; + final List routineList; - const HomeTodayRoutineButton({super.key, required this.isCompleted, required this.routineId}); + const HomeTodayRoutineButton({ + super.key, + required this.isCompleted, + required this.routineId, + required this.routineList, + }); @override Widget build(BuildContext context, WidgetRef ref) { - return GestureDetector( - onTap: () async { - if (!ref.watch(homeTodayRoutineController).statusCode.isLoading) { - if(isCompleted){ - await ref - .read(homeTodayRoutineController.notifier) - .incompleteTodayRoutines(routineId); - } - - if(!isCompleted){ - await ref - .read(homeTodayRoutineController.notifier) - .completeTodayRoutines(routineId); - } + return Container( + width: MediaQuery.of(context).size.width, + height: 98, + alignment: Alignment.center, + decoration: BoxDecoration( + color: MaeumgagymColor.white, + border: Border.all(color: MaeumgagymColor.gray50), + ), + child: Padding( + padding: const EdgeInsets.all(20), + child: Builder( + builder: (context) { + if (isCompleted) { + return Container( + decoration: BoxDecoration( + color: MaeumgagymColor.gray100, + borderRadius: BorderRadius.circular(8), + ), + child: Center( + child: PtdTextWidget.labelLarge( + "루틴 완료함", + MaeumgagymColor.gray300, + ), + ), + ); + } else { + return GestureDetector( + onTap: () async { + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => RoutineStartMainScreen( + routineId: routineId, + routineList: routineList + ), + ), + ); - await ref - .read(homeTodayRoutineController.notifier) - .getTodayRoutines(); - } - }, - child: Container( - width: MediaQuery.of(context).size.width, - height: 98, - alignment: Alignment.center, - decoration: BoxDecoration( - color: MaeumgagymColor.white, - border: Border.all(color: MaeumgagymColor.gray50), - ), - child: Padding( - padding: const EdgeInsets.all(20), - child: Container( - decoration: BoxDecoration( - color: isCompleted - ? MaeumgagymColor.blue50 - : MaeumgagymColor.blue500, - borderRadius: BorderRadius.circular(8), - ), - child: Center( - child: PtdTextWidget.bodyLarge( - isCompleted ? '루틴 완료 취소하기' : '루틴 완료하기', - isCompleted ? MaeumgagymColor.blue500 : MaeumgagymColor.white, - ), - ), - ), + ref.read(routineStartPageViewProvider.notifier).state = 0; + }, + child: Container( + decoration: BoxDecoration( + color: MaeumgagymColor.blue500, + borderRadius: BorderRadius.circular(8), + ), + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ImageWidget( + width: 24, + image: Images.mediaPlayFilled, + color: MaeumgagymColor.white, + ), + const SizedBox(width: 8), + PtdTextWidget.labelLarge("루틴 시작하기", MaeumgagymColor.white) + ], + ), + ), + ), + ); + } + }, ), ), );