Skip to content

Commit

Permalink
Merge pull request #29 from canopas/Mayank/refactor-add-team-member-s…
Browse files Browse the repository at this point in the history
…creen

Refactor add team member
  • Loading branch information
cp-mayank authored May 30, 2024
2 parents 7f689ee + 4151b68 commit c284ec4
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 305 deletions.
2 changes: 2 additions & 0 deletions khelo/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@
"add_team_add_as_member_description_text": "Add me as a team member",
"add_team_enter_team_name_placeholder_text": "Enter team name",
"add_team_location_text": "Location",
"add_team_player_role_title": "Playing role",
"add_team_players_text": "Players",
"add_team_add_hint_text": "Added user will be shown here, tap on '+' button to add team member.",
"add_team_member_screen_title": "Add team member",
"add_team_member_details_title": "Details",
"add_team_member_search_placeholder_text": "Search member name",
"add_team_member_verify_placeholder_text": "Enter the last five digits of the phone number of the selected player.",
"add_team_member_verify_title": "Verify",
Expand Down
4 changes: 3 additions & 1 deletion khelo/lib/domain/formatter/date_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';
import 'package:khelo/domain/extensions/context_extensions.dart';

enum DateFormatType { dateAndTime, date, time, shortDate }
enum DateFormatType { dateAndTime, date, time, shortDate, dayMonthYear }

extension DateFormatter on DateTime {
String format(BuildContext context, DateFormatType type) {
Expand All @@ -20,6 +20,8 @@ extension DateFormatter on DateTime {
.format(this);
case DateFormatType.shortDate:
return DateFormat('dd MMM yyyy').format(this);
case DateFormatType.dayMonthYear:
return DateFormat.yMMMd().format(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:data/api/user/user_models.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:khelo/components/image_avatar.dart';
import 'package:khelo/domain/extensions/context_extensions.dart';
import 'package:khelo/domain/formatter/date_formatter.dart';
import 'package:khelo/domain/formatter/string_formatter.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:khelo/domain/extensions/enum_extensions.dart';
Expand Down Expand Up @@ -35,118 +35,117 @@ class UserDetailSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: context.mediaQueryPadding +
const EdgeInsets.only(bottom: 24, left: 16, right: 16),
child: Wrap(
alignment: WrapAlignment.center,
padding: context.mediaQueryPadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_nameText(context),
Divider(
height: 32,
color: context.colorScheme.outline,
thickness: 2,
_memberProfile(context),
Divider(color: context.colorScheme.outline),
Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
context.l10n.add_team_member_details_title,
style: AppTextStyle.header4.copyWith(
color: context.colorScheme.textPrimary,
),
),
),
_textDividerView(
_memberDetailCell(
context,
title1: user.location.toString(),
title2: user.gender?.getString(context) ?? "",
label: context.l10n.edit_profile_gender_placeholder,
value: user.gender?.getString(context),
),
Divider(
height: 32,
color: context.colorScheme.outline,
thickness: 2,
_memberDetailCell(
context,
label: context.l10n.add_team_location_text,
value: user.location.toString(),
),
_memberDetailCell(
context,
label: context.l10n.add_team_player_role_title,
value: user.player_role?.getString(context),
),
_memberDetailCell(
context,
label: context.l10n.edit_profile_batting_style_placeholder,
value: user.batting_style?.getString(context),
),
_memberDetailCell(
context,
label: context.l10n.edit_profile_bowling_style_placeholder,
value: user.bowling_style?.getString(context),
),
_textDividerView(context,
title1: user.player_role?.getString(context),
title2: user.batting_style?.getString(context),
title3: user.bowling_style?.getString(context)),
],
),
);
}

Widget _nameText(BuildContext context) {
return Row(
children: [
ImageAvatar(
Widget _memberProfile(BuildContext context) {
return Material(
type: MaterialType.transparency,
child: ListTile(
dense: true,
leading: ImageAvatar(
initial: user.nameInitial,
imageUrl: user.profile_img_url,
size: 70,
size: 40,
),
Expanded(
child: Column(
children: [
Text(
user.name ?? context.l10n.common_anonymous_title,
style: AppTextStyle.subtitle1.copyWith(
color: context.colorScheme.textPrimary, fontSize: 20),
),
Text(
user.phone.format(context, StringFormats.obscurePhoneNumber),
style: AppTextStyle.subtitle1.copyWith(
color: context.colorScheme.textPrimary, fontSize: 20),
),
],
),
title: Text(
user.name ?? context.l10n.common_anonymous_title,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary),
),
Text.rich(
textAlign: TextAlign.right,
TextSpan(
text: context.l10n.add_match_joined_on_title,
style: AppTextStyle.body2
.copyWith(color: context.colorScheme.textSecondary),
children: [
TextSpan(
text:
"\n${DateFormat.yMMMd().format(user.created_at ?? DateTime.now())}",
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textSecondary))
])),
],
subtitle: Text(
user.phone.format(context, StringFormats.obscurePhoneNumber),
style: AppTextStyle.body2
.copyWith(color: context.colorScheme.textDisabled),
),
trailing: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
context.l10n.add_match_joined_on_title,
style: AppTextStyle.caption
.copyWith(color: context.colorScheme.textDisabled),
),
Text(
(user.created_at ?? DateTime.now())
.format(context, DateFormatType.dayMonthYear),
style: AppTextStyle.body2
.copyWith(color: context.colorScheme.textPrimary),
),
],
),
),
);
}

Widget _textDividerView(
Widget _memberDetailCell(
BuildContext context, {
required String? title1,
required String? title2,
String? title3,
required String label,
required String? value,
}) {
return IntrinsicHeight(
if (value == null) return const SizedBox();

return Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (title1 != null) ...[
Text(
title1,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary),
),
],
if (title2 != null) ...[
VerticalDivider(
thickness: 2,
color: context.colorScheme.outline,
width: 24,
Text(
label,
style: AppTextStyle.body1.copyWith(
color: context.colorScheme.textDisabled,
),
Text(
title2,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary),
),
],
if (title3 != null) ...[
VerticalDivider(
thickness: 2,
color: context.colorScheme.outline,
width: 24,
),
Text(
title3,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary),
),
Text(
value,
style: AppTextStyle.body2.copyWith(
color: context.colorScheme.textPrimary,
),
],
)
],
),
);
Expand Down
Loading

0 comments on commit c284ec4

Please sign in to comment.