Skip to content

Commit

Permalink
FEAT :: home_today_routine_button에 routineStartScreen적용
Browse files Browse the repository at this point in the history
  • Loading branch information
ljyo2o9 committed Jul 11, 2024
1 parent 1516ed4 commit df1fea3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 45 deletions.
1 change: 1 addition & 0 deletions lib/home/presentation/view/home_today_routine_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class HomeTodayRoutineScreen extends ConsumerWidget {
bottomSheet: HomeTodayRoutineButton(
isCompleted: todayRoutine.isCompleted!,
routineId: todayRoutine.id!,
routineList: todayRoutine.exerciseInfoResponseList!,
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ExerciseInfoList> 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)
],
),
),
),
);
}
},
),
),
);
Expand Down

0 comments on commit df1fea3

Please sign in to comment.