Skip to content

Commit

Permalink
Merge branch 'release/0.9.93+124' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ljyo2o9 committed Aug 21, 2024
2 parents 63b67f3 + b22e274 commit 851e695
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class PosePartWidget extends StatelessWidget {
poseData: poseData,
repetitionsController: TextEditingController(text: "10"),
setsController: TextEditingController(text: "1"),
repetitionsNode: FocusNode(),
setsNode: FocusNode(),
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class PoseRecommendWidgetBottom extends StatelessWidget {
poseData: poseData,
repetitionsController: TextEditingController(text: "10"),
setsController: TextEditingController(text: "1"),
repetitionsNode: FocusNode(),
setsNode: FocusNode(),
),
);
MaeumNavigator.pop(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ class RoutineAddPoseListStateModel {
PoseEntity poseData;
/// 포즈 repetitions의 값을 관리하는 컨트롤러
final TextEditingController repetitionsController;
final FocusNode repetitionsNode;
/// 포즈 sets의 값을 관리하는 컨트롤러
final TextEditingController setsController;
final FocusNode setsNode;


RoutineAddPoseListStateModel({
required this.poseData,
required this.repetitionsController,
required this.repetitionsNode,
required this.setsController,
required this.setsNode,
});
}
256 changes: 136 additions & 120 deletions lib/presentation/purpose/ui/view/purpose_add_edit_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:maeumgagym_flutter/component/maeum_toast_message.dart';
import 'package:maeumgagym_flutter/component/my_scaffold.dart';
import 'package:maeumgagym_flutter/core/enum/bloc_state_enum.dart';
import 'package:maeumgagym_flutter/core/maeum/maeum_navigation.dart';
import 'package:maeumgagym_flutter/data/purpose/dto/request/add_purpsoe_request.dart';
import 'package:maeumgagym_flutter/domain/purposes/entity/purposes_entity.dart';
import 'package:maeumgagym_flutter/presentation/purpose/ui/widget/purpose_add_edit/purpose_add_edit_app_bar.dart';
import 'package:maeumgagym_flutter/presentation/purpose/ui/widget/purpose_add_edit/purpose_add_edit_botton.dart';
import 'package:maeumgagym_flutter/presentation/purpose/ui/widget/purpose_add_edit/purpose_add_edit_date_widget.dart';
Expand All @@ -15,6 +17,7 @@ import 'package:maeumgagym_flutter/presentation/purpose/view_model/purpose/purpo
import 'package:maeumgagym_flutter/presentation/purpose/view_model/purpose_add_edit/purpose_calender_state_cubit.dart';
import 'package:maeumgagym_flutter/presentation/purpose/view_model/purpose_date_format_func.dart';
import 'package:maeumgagym_flutter/presentation/purpose/view_model/purposes/purposes_event.dart';
import 'package:maeumgagym_flutter/presentation/purpose/view_model/purposes/purposes_state.dart';
import 'package:top_snackbar_flutter/top_snack_bar.dart';

import '../../../../domain/purposes/entity/purpose_entity.dart';
Expand Down Expand Up @@ -73,130 +76,143 @@ class _PurposeAddEditScreenState extends State<PurposeAddEditScreen> {
Widget build(BuildContext context) {
bool isAdd = widget.purposeData == null;

return MyScaffold(
appBar: PurposeAddEditAppBar(isAdd: isAdd),
bottomSheet: Padding(
padding: EdgeInsets.only(bottom: 20.h),
child: PurposeAddEditButton(
onTap: () {
String startDate = PurposeDateFormatFunc.formatPostDate(
context.read<PurposeStartCalender>().state.date);

String endDate = PurposeDateFormatFunc.formatPostDate(
context.read<PurposeEndCalender>().state.date);

int compareDate = startDate.compareTo(endDate);

if(_titleController.text.isNotEmpty && _contentController.text.isNotEmpty && compareDate <= 0){
final AddEditPurposeRequest request = AddEditPurposeRequest(
title: _titleController.text,
content: _contentController.text,
startDate: startDate,
endDate: endDate,
);

if(isAdd){
context.read<PurposesBloc>().add(
AddPurposeEvent(addEditPurposeRequest: request));
} else {
context.read<PurposesBloc>().add(EditPurposeEvent(
purposeId: widget.purposeData!.id,
addEditPurposeRequest: request,
));

context.read<PurposeBloc>().add(GetPurposeDetailEvent(purposeId: widget.purposeData!.id));
}
return MultiBlocListener(
listeners: [
BlocListener<PurposesBloc, PurposesState<PurposesEntity>>(
listenWhen: (previous, current) => current.purposesState == BlocStateEnum.loaded,
listener: (context, state) {
showTopSnackBar(Overlay.of(context), MaeumToastMessage(title: "목표를 ${isAdd ? "추가" : "수정"}했어요."));

MaeumNavigator.pop(context);
!isAdd ? MaeumNavigator.pop(context) : null;
} else {
showTopSnackBar(
Overlay.of(context),
const MaeumToastMessage(title: "목표 추가에 실패했어요", isError: true),
);
}
MaeumNavigator.pop(context);
!isAdd ? MaeumNavigator.pop(context) : null;
},
),
),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 24.h, horizontal: 20.w),
child: Column(
children: [
PurposeAddEditTextField(
title: "제목",
controller: _titleController,
focusNode: _titleNode,
hintText: "제목을 입력해주세요.",
height: 48.h,
),

SizedBox(height: 32.h),

BlocBuilder<PurposeStartCalender, PurposeCalenderModel>(
builder: (_, state) {
return GestureDetector(
onTap: () {
PurposeStartCalender notifier = context.read<PurposeStartCalender>();

if(context.read<PurposeEndCalender>().state.isActive){
context.read<PurposeEndCalender>().overlayRemove();
}

if (notifier.state.isActive) {
notifier.overlayRemove();
setState(() {});
} else {
notifier.overlayCalenderInset(context: context);
setState(() {});
}
},
child: PurposeAddEditDateWidget(
title: "시작 날짜",
state: state,
),
);
}
),

SizedBox(height: 32.h),

BlocBuilder<PurposeEndCalender, PurposeCalenderModel>(
builder: (_, state) {
return GestureDetector(
onTap: () {
PurposeCalenderStateCubit notifier = context.read<PurposeEndCalender>();

if(context.read<PurposeStartCalender>().state.isActive){
context.read<PurposeStartCalender>().overlayRemove();
}

if (notifier.state.isActive) {
notifier.overlayRemove();
setState(() {});
} else {
notifier.overlayCalenderInset(context: context);
setState(() {});
}
},
child: PurposeAddEditDateWidget(
title: "종료 날짜",
state: state,
),
);
],
child: MyScaffold(
appBar: PurposeAddEditAppBar(isAdd: isAdd),
bottomSheet: Padding(
padding: EdgeInsets.only(bottom: 20.h),
child: PurposeAddEditButton(
onTap: () {
String startDate = PurposeDateFormatFunc.formatPostDate(
context.read<PurposeStartCalender>().state.date);

String endDate = PurposeDateFormatFunc.formatPostDate(
context.read<PurposeEndCalender>().state.date);

int compareDate = startDate.compareTo(endDate);

if(_titleController.text.isNotEmpty && _contentController.text.isNotEmpty && compareDate <= 0){
final AddEditPurposeRequest request = AddEditPurposeRequest(
title: _titleController.text,
content: _contentController.text,
startDate: startDate,
endDate: endDate,
);

if(isAdd){
context.read<PurposesBloc>().add(
AddPurposeEvent(addEditPurposeRequest: request));
} else {
context.read<PurposesBloc>().add(EditPurposeEvent(
purposeId: widget.purposeData!.id,
addEditPurposeRequest: request,
));

context.read<PurposeBloc>().add(GetPurposeDetailEvent(purposeId: widget.purposeData!.id));
}
),

SizedBox(height: 32.h),

PurposeAddEditTextField(
title: "내용",
controller: _contentController,
focusNode: _contentNode,
hintText: "내용을 입력해주세요.",
height: 200.h,
),
],

// MaeumNavigator.pop(context);
// !isAdd ? MaeumNavigator.pop(context) : null;
} else {
showTopSnackBar(
Overlay.of(context),
const MaeumToastMessage(title: "목표 추가에 실패했어요", isError: true),
);
}
},
),
),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 24.h, horizontal: 20.w),
child: Column(
children: [
PurposeAddEditTextField(
title: "제목",
controller: _titleController,
focusNode: _titleNode,
hintText: "제목을 입력해주세요.",
height: 48.h,
),

SizedBox(height: 32.h),

BlocBuilder<PurposeStartCalender, PurposeCalenderModel>(
builder: (_, state) {
return GestureDetector(
onTap: () {
PurposeStartCalender notifier = context.read<PurposeStartCalender>();

if(context.read<PurposeEndCalender>().state.isActive){
context.read<PurposeEndCalender>().overlayRemove();
}

if (notifier.state.isActive) {
notifier.overlayRemove();
setState(() {});
} else {
notifier.overlayCalenderInset(context: context);
setState(() {});
}
},
child: PurposeAddEditDateWidget(
title: "시작 날짜",
state: state,
),
);
}
),

SizedBox(height: 32.h),

BlocBuilder<PurposeEndCalender, PurposeCalenderModel>(
builder: (_, state) {
return GestureDetector(
onTap: () {
PurposeCalenderStateCubit notifier = context.read<PurposeEndCalender>();

if(context.read<PurposeStartCalender>().state.isActive){
context.read<PurposeStartCalender>().overlayRemove();
}

if (notifier.state.isActive) {
notifier.overlayRemove();
setState(() {});
} else {
notifier.overlayCalenderInset(context: context);
setState(() {});
}
},
child: PurposeAddEditDateWidget(
title: "종료 날짜",
state: state,
),
);
}
),

SizedBox(height: 32.h),

PurposeAddEditTextField(
title: "내용",
controller: _contentController,
focusNode: _contentNode,
hintText: "내용을 입력해주세요.",
height: 200.h,
),
],
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import 'package:maeumgagym_flutter/domain/purposes/entity/purpose_entity.dart';
import 'package:maeumgagym_flutter/presentation/purpose/ui/view/purpose_add_edit_screen.dart';
import 'package:maeumgagym_flutter/presentation/purpose/ui/widget/purpose_manager_item_widget.dart';
import 'package:maeumgagym_flutter/presentation/purpose/view_model/purposes/purposes_event.dart';
import 'package:top_snackbar_flutter/top_snack_bar.dart';

import '../../../../component/maeum_toast_message.dart';
import '../../../../core/images.dart';
import '../../../../core/maeum/maeum_color.dart';
import '../../view_model/purposes/purposes_bloc.dart';
Expand Down Expand Up @@ -53,7 +55,10 @@ class PurposeManagerBottomSheet extends StatelessWidget {
children: [
/// 수정 버튼
PurposeManagerItemWidget(
onTap: () => MaeumNavigator.push(context, PurposeAddEditScreen(purposeData: purposeData)),
onTap: () {
MaeumNavigator.pop(context);
MaeumNavigator.push(context, PurposeAddEditScreen(purposeData: purposeData));
},
title: "수정",
image: Images.editPencil,
),
Expand All @@ -64,6 +69,8 @@ class PurposeManagerBottomSheet extends StatelessWidget {
MaeumNavigator.pop(context);
inDetail ? MaeumNavigator.pop(context) : null;

showTopSnackBar(Overlay.of(context), const MaeumToastMessage(title: "목표를 삭제했어요.", isError: true),);

context.read<PurposesBloc>().add(DelPurposeEvent(purposeId: purposeData.id));
},
title: "삭제",
Expand Down
Loading

0 comments on commit 851e695

Please sign in to comment.