Skip to content

Commit

Permalink
Merge pull request #53 from canopas/Mayank/add-more-option-team-detail
Browse files Browse the repository at this point in the history
Add more options in team detail
  • Loading branch information
cp-mayank authored Jun 20, 2024
2 parents d7194ca + b62f13c commit c32b22a
Showing 1 changed file with 66 additions and 29 deletions.
95 changes: 66 additions & 29 deletions khelo/lib/ui/flow/team/detail/team_detail_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:khelo/components/action_bottom_sheet.dart';
import 'package:khelo/components/app_page.dart';
import 'package:khelo/components/error_screen.dart';
import 'package:khelo/components/image_avatar.dart';
Expand Down Expand Up @@ -57,7 +61,22 @@ class _TeamDetailScreenState extends ConsumerState<TeamDetailScreen> {
final state = ref.watch(teamDetailStateProvider);
return AppPage(
title: state.team?.name ?? context.l10n.team_detail_screen_title,
body: _body(context, state),
actions: (state.currentUserId == state.team?.created_by)
? [
actionButton(
context,
icon: Icon(
Platform.isIOS
? Icons.more_horiz_rounded
: Icons.more_vert_rounded,
color: context.colorScheme.textPrimary),
onPressed: () => _moreActionButton(context, state),
),
]
: null,
body: Builder(builder: (context) {
return _body(context, state);
}),
);
}

Expand All @@ -72,21 +91,18 @@ class _TeamDetailScreenState extends ConsumerState<TeamDetailScreen> {
);
}

return Column(
mainAxisSize: MainAxisSize.min,
children: [
_teamProfileView(context, state),
const SizedBox(height: 16),
_tabView(
context,
onAddButtonTap: () => AppRoute.addMatch(
defaultTeam: (state.team?.players?.length ?? 0) >= 2
? state.team
: null)
.push(context),
),
_content(context),
],
return Padding(
padding:
context.mediaQueryPadding + const EdgeInsets.symmetric(vertical: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_teamProfileView(context, state),
const SizedBox(height: 16),
_tabView(context),
_content(context),
],
),
);
}

Expand Down Expand Up @@ -127,10 +143,7 @@ class _TeamDetailScreenState extends ConsumerState<TeamDetailScreen> {
);
}

Widget _tabView(
BuildContext context, {
required Function() onAddButtonTap,
}) {
Widget _tabView(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
Expand All @@ -152,15 +165,6 @@ class _TeamDetailScreenState extends ConsumerState<TeamDetailScreen> {
selected: _selectedTab == 2,
onTap: () => _controller.jumpToPage(2),
),
if (_selectedTab == 0) ...[
const Spacer(),
actionButton(context,
onPressed: onAddButtonTap,
icon: Icon(
Icons.add,
color: context.colorScheme.textPrimary,
)),
],
],
),
);
Expand All @@ -179,6 +183,39 @@ class _TeamDetailScreenState extends ConsumerState<TeamDetailScreen> {
);
}

void _moreActionButton(
BuildContext context,
TeamDetailState state,
) async {
return showActionBottomSheet(context: context, items: [
BottomSheetAction(
title: context.l10n.common_edit_team_title,
onTap: () {
context.pop();
AppRoute.addTeam(team: state.team).push(context);
},
),
BottomSheetAction(
title: context.l10n.add_match_screen_title,
onTap: () {
context.pop();
AppRoute.addMatch(
defaultTeam: (state.team?.players?.length ?? 0) >= 2
? state.team
: null)
.push(context);
},
),
BottomSheetAction(
title: context.l10n.team_list_add_members_title,
onTap: () {
context.pop();
AppRoute.addTeamMember(team: state.team!).push(context);
},
),
]);
}

@override
void dispose() {
_controller.dispose();
Expand Down

0 comments on commit c32b22a

Please sign in to comment.