Skip to content

Commit

Permalink
Merge pull request #43 from thaidmfinnick/develop
Browse files Browse the repository at this point in the history
build(prod): 1.0.0+1
  • Loading branch information
thaidmfinnick authored Jan 2, 2025
2 parents 9ae00c4 + 865e823 commit 0cb543c
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 128 deletions.
7 changes: 5 additions & 2 deletions api/lib/cecr_unwomen_web/controllers/user_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ defmodule CecrUnwomenWeb.UserController do
{_, refresh_token, _} = Helper.create_token(data_jwt, :refresh_token)
{_, access_token, access_exp} = Helper.create_token(data_jwt, :access_token)

birth = if is_nil(birth), do: nil, else: Date.from_iso8601!(birth)
birth = if is_nil(birth), do: nil, else:
String.split(birth, "T")
|> List.first()
|> Date.from_iso8601!()

User.changeset(%User{}, %{
id: user_id,
Expand All @@ -48,7 +51,7 @@ defmodule CecrUnwomenWeb.UserController do
phone_number: phone_number,
password_hash: password_hash,
refresh_token: refresh_token,
birth: birth,
date_of_birth: birth,
location: location,
gender: gender
})
Expand Down
27 changes: 24 additions & 3 deletions mobile/lib/features/login/view/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:cecr_unwomen/constants/color_constants.dart';
import 'package:cecr_unwomen/features/authentication/repository/authentication_repository.dart';
import 'package:cecr_unwomen/features/home/view/component/toast_content.dart';
import 'package:cecr_unwomen/features/login/login.dart';
import 'package:cecr_unwomen/utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -471,11 +472,31 @@ class _RegisterBoxState extends State<RegisterBox> {
],
),
const SizedBox(height: 12),
_buildHeaderWidget("Ngày sinh"),
_buildHeaderWidget("Ngày sinh (không bắt buộc)"),
InkWell(
radius: 8,
// canRequestFocus: false,
onTap: () => _showDatePicker(),
onTap: () => Utils.showDatePicker(
context: context,
initDate: _selectedDate ,
onCancel: () {
setState(() {
_selectedDate = null;
});
registerData["birth"] = "";
Navigator.pop(context);
},
onSave: () {
setState(() {
_selectedDate = _selectedDate ?? DateTime.now();
});
registerData["birth"] = _selectedDate!.toIso8601String();
Navigator.pop(context);
},
onDateTimeChanged: (date) {
_selectedDate = date;
}
),
child: Container(
height: 44,
padding: const EdgeInsets.symmetric(horizontal: 16),
Expand Down Expand Up @@ -709,7 +730,7 @@ class _RegisterBoxState extends State<RegisterBox> {

const SizedBox(height: 12),
CustomTextField(
label: "Địa chỉ",
label: "Địa chỉ (không bắt buộc)",
placeholder: "địa chỉ",
keyword: "location",
hasBorder: false,
Expand Down
84 changes: 16 additions & 68 deletions mobile/lib/features/user/view/screen/change_info_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:cecr_unwomen/features/authentication/models/user.dart';
import 'package:cecr_unwomen/features/home/view/component/header_widget.dart';
import 'package:cecr_unwomen/features/home/view/component/toast_content.dart';
import 'package:cecr_unwomen/features/user/repository/user_api.dart';
import 'package:cecr_unwomen/utils.dart';
import 'package:cecr_unwomen/widgets/circle_avatar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart';
Expand Down Expand Up @@ -133,7 +133,21 @@ class _ChangeInfoScreenState extends State<ChangeInfoScreen> {
_buildDateField(
label: 'Ngày sinh',
value: birthDate,
onTap: () => _showDatePicker()
onTap: () => Utils.showDatePicker(
context: context,
onCancel: () {
birthDate = DateTime.parse(birthDateController.text);
Navigator.pop(context);
},
onSave: () {
birthDate = birthDate ?? DateTime.now();
birthDateController.text = DateFormat("dd/MM/yyyy").format(birthDate!);
Navigator.pop(context);
},
onDateTimeChanged: (date) {
birthDate = date;
},
)
),
const SizedBox(height: 16),
_buildGenderSelection(),
Expand Down Expand Up @@ -205,72 +219,6 @@ class _ChangeInfoScreenState extends State<ChangeInfoScreen> {
);
}



void _showDatePicker() {
showCupertinoModalPopup<void>(
context: context,
builder: (BuildContext context) => Material(
borderRadius: const BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12)),
child: ClipRRect(
borderRadius: const BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12)),
child: Container(
height: 300,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 3),
color: const Color(0xffFFFFFF),
child: Column(
children: [
Container(
height: 5,
width: 45,
margin: const EdgeInsets.only(top: 6, bottom: 12),
decoration: BoxDecoration(
color: const Color(0xffC1C1C2),
borderRadius: BorderRadius.circular(100)
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
birthDate = DateTime.parse(birthDateController.text);
Navigator.pop(context);
} ,
child: Text("Huỷ", style: colorConstants.fastStyle(16, FontWeight.w500, const Color(0xff4CAF50)),)
),
Text("Chọn thời gian", style: colorConstants.fastStyle(16, FontWeight.w700, const Color(0xff29292A)),),
InkWell(
onTap: () {
birthDate = birthDate ?? DateTime.now();
birthDateController.text = DateFormat("dd/MM/yyyy").format(birthDate!);
// setState(() => userClone = userClone.copyWith(dateOfBirth: birthDate));
Navigator.pop(context);
} ,
child: Text("Lưu", style: colorConstants.fastStyle(16, FontWeight.w500, const Color(0xff4CAF50)),)
)
],
),
Flexible(
child: CupertinoDatePicker(
initialDateTime: userClone.dateOfBirth ?? DateTime.now(),
mode: CupertinoDatePickerMode.date,
use24hFormat: true,
onDateTimeChanged: (DateTime newDate) {
birthDate = newDate;
},
dateOrder: DatePickerDateOrder.dmy,
),
)
],
)
),
),
),
);
}


Widget _buildTextField({
required String label,
required TextEditingController controller,
Expand Down
78 changes: 61 additions & 17 deletions mobile/lib/features/user/view/user_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:cecr_unwomen/features/user/view/screen/change_info_screen.dart';
import 'package:cecr_unwomen/utils.dart';
import 'package:cecr_unwomen/widgets/circle_avatar.dart';
import 'package:cecr_unwomen/widgets/navigation_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
Expand Down Expand Up @@ -40,21 +41,27 @@ class _UserInfoState extends State<UserInfo> {
const SizedBox(height: 10),
Text("${user.firstName} ${user.lastName}", style: colorCons.fastStyle(18,FontWeight.w700, const Color(0xFF333334))),
const SizedBox(height: 10),
Text(user.roleId == 1 ? "Admin" :
user.roleId == 2 ? "Hộ gia đình" : "Người thu gom",
style: colorCons.fastStyle(16, FontWeight.w400, colorCons.textSubHeader)),
Text(
user.roleId == 1
? "Admin"
: user.roleId == 2
? "Hộ gia đình"
: "Người thu gom",
style: colorCons.fastStyle(
16, FontWeight.w400, colorCons.textSubHeader)),
const SizedBox(height: 12),
Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(12),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => BlocProvider.value(
value: BlocProvider.of<AuthenticationBloc>(this.context),
child: const ChangeInfoScreen()))
);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BlocProvider.value(
value: BlocProvider.of<AuthenticationBloc>(
this.context),
child: const ChangeInfoScreen())));
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
Expand All @@ -67,26 +74,63 @@ class _UserInfoState extends State<UserInfo> {
),
),
const SizedBox(height: 20),
NavigationButton(
text: "Nhắc nhập liệu",
icon: PhosphorIcons.regular.alarm,
hasSwitch: true,
onToggleSwitch: (p0) {
return Utils.showDialogWarningError(
context, false, "Chức năng đang được phát triển");
},
subTitleWidget: Column(
children: [
Text(
"Ứng dụng sẽ gửi thông báo nhắc bạn nhập dữ liệu mỗi ngày",
style: colorCons.fastStyle(14, FontWeight.w400, const Color(0xff666667)),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 6.0),
child: Divider(color: Color(0xffF4F4F5)),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Thời gian", style: colorCons.fastStyle(16, FontWeight.w600, const Color(0xff333334)),),
InkWell(
onTap: () => Utils.showDatePicker(
context: context,
onCancel: () => Navigator.pop(context),
onSave: () => Navigator.pop(context),
onDateTimeChanged: (p0) {
// return Utils.showDialogWarningError(context, false, "Chức năng đang được phát triển");
},
mode: CupertinoDatePickerMode.time
),
child: Text("14:00", style: colorCons.fastStyle(14, FontWeight.w500, const Color(0xff4CAF50)),)
)
],
)
],
),
),
NavigationButton(
text: "Về chúng tôi",
icon: PhosphorIcons.regular.users,
onTap: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => AppInfo())
),
onTap: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => AppInfo())),
),
NavigationButton(
text: "Thay đổi mật khẩu",
icon: PhosphorIcons.regular.lock,
onTap: () => Utils.showDialogWarningError(context, false, "Chức năng đang được phát triển"),
onTap: () => Utils.showDialogWarningError(
context, false, "Chức năng đang được phát triển"),
),
NavigationButton(
text: "Xác thực sinh trắc học",
icon: PhosphorIcons.regular.fingerprint,
hasSwitch: true,
onToggleSwitch: (p0) {
return Utils.showDialogWarningError(context, false, "Chức năng đang được phát triển");
},
onToggleSwitch: (p0) => Utils.showDialogWarningError(
context, false, "Chức năng đang được phát triển"),
),
NavigationButton(
text: "Đăng xuất",
Expand Down
71 changes: 71 additions & 0 deletions mobile/lib/utils.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:cecr_unwomen/constants/color_constants.dart';
import 'package:cecr_unwomen/secrets.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

Expand Down Expand Up @@ -66,4 +67,74 @@ class Utils {
}
);
}

static void showDatePicker({
required BuildContext context,
required Function() onCancel,
required Function() onSave,
required void Function(DateTime) onDateTimeChanged,
DateTime? initDate,
CupertinoDatePickerMode mode = CupertinoDatePickerMode.date,
}) {
showCupertinoModalPopup<void>(
context: context,
builder: (BuildContext context) => Material(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12), topRight: Radius.circular(12)),
child: ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(12), topRight: Radius.circular(12)),
child: Container(
height: 300,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 3),
color: const Color(0xffFFFFFF),
child: Column(
children: [
Container(
height: 5,
width: 45,
margin: const EdgeInsets.only(top: 6, bottom: 12),
decoration: BoxDecoration(
color: const Color(0xffC1C1C2),
borderRadius: BorderRadius.circular(100)),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: onCancel,
child: Text(
"Huỷ",
style: ColorConstants().fastStyle(
16, FontWeight.w500, const Color(0xff4CAF50)),
)),
Text(
"Chọn thời gian",
style: ColorConstants().fastStyle(
16, FontWeight.w700, const Color(0xff29292A)),
),
InkWell(
onTap: onSave,
child: Text(
"Lưu",
style: ColorConstants().fastStyle(
16, FontWeight.w500, const Color(0xff4CAF50)),
))
],
),
Flexible(
child: CupertinoDatePicker(
initialDateTime: initDate ?? DateTime.now(),
mode: mode,
use24hFormat: true,
onDateTimeChanged: onDateTimeChanged,
dateOrder: DatePickerDateOrder.dmy,
),
)
],
)),
),
),
);
}
}
Loading

0 comments on commit 0cb543c

Please sign in to comment.