Skip to content

Commit

Permalink
Merge pull request #40 from canopas/Mayank/add-five-seven-run-sheet
Browse files Browse the repository at this point in the history
Add five seven runs option sheet
  • Loading branch information
cp-mayank authored Jun 10, 2024
2 parents a33ce02 + e0ca6c2 commit a6616e8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 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 @@ -517,6 +517,8 @@
"score_board_six_text": "6",
"score_board_six_title": "Six",
"score_board_five_or_seven_text": "5, 7",
"score_board_five_text": "5",
"score_board_seven_text": "7",
"score_board_out_text": "OUT",
"score_board_wicket_text": "WICKET",
"score_board_leg_bye_text": "LB",
Expand Down
68 changes: 60 additions & 8 deletions khelo/lib/ui/flow/score_board/components/add_extra_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:khelo/domain/extensions/context_extensions.dart';
import 'package:khelo/ui/flow/score_board/components/bottom_sheet_wrapper.dart';
import 'package:style/animations/on_tap_scale.dart';
import 'package:style/button/primary_button.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:style/text/app_text_field.dart';
Expand Down Expand Up @@ -56,7 +57,6 @@ class AddExtraSheet extends StatefulWidget {
class _AddExtraSheetState extends State<AddExtraSheet> {
bool notFromBat = false;
bool isBoundary = false;
bool isButtonEnable = false;

TextEditingController runController = TextEditingController();

Expand All @@ -67,7 +67,7 @@ class _AddExtraSheetState extends State<AddExtraSheet> {
action: [
PrimaryButton(
context.l10n.common_next_title,
enabled: isButtonEnable,
enabled: runController.text.isNotEmpty,
onPressed: () {
context.pop((
int.parse(runController.text),
Expand All @@ -92,11 +92,66 @@ class _AddExtraSheetState extends State<AddExtraSheet> {
.copyWith(color: context.colorScheme.textPrimary),
),
const SizedBox(height: 16),
_addRunsView(context),
if (widget.isFiveSeven) ...[
Wrap(
spacing: 16,
children: [
_runButton(
text: context.l10n.score_board_five_text,
onTap: () {
setState(() {
runController.text = context.l10n.score_board_five_text;
});
},
selected: runController.text.contains(
context.l10n.score_board_five_text,
),
),
_runButton(
text: context.l10n.score_board_seven_text,
onTap: () {
setState(() {
runController.text = context.l10n.score_board_seven_text;
});
},
selected: runController.text.contains(
context.l10n.score_board_seven_text,
),
),
],
),
] else ...[
_addRunsView(context),
],
],
);
}

Widget _runButton({
required text,
required Function() onTap,
required bool selected,
}) {
return OnTapScale(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 24),
decoration: BoxDecoration(
color: context.colorScheme.containerLow,
borderRadius: BorderRadius.circular(12),
border: selected
? Border.all(color: context.colorScheme.primary)
: null),
child: Text(
text,
style: AppTextStyle.subtitle1.copyWith(
color: context.colorScheme.textPrimary,
),
),
),
);
}

Widget _addRunsView(BuildContext context) {
return Container(
padding: const EdgeInsets.all(16),
Expand Down Expand Up @@ -136,8 +191,7 @@ class _AddExtraSheetState extends State<AddExtraSheet> {
],
style: AppTextStyle.subtitle2
.copyWith(color: context.colorScheme.textPrimary),
onChanged: (value) =>
setState(() => isButtonEnable = value.isNotEmpty),
onChanged: (_) => setState(() {}),
),
),
),
Expand Down Expand Up @@ -208,9 +262,7 @@ class _AddExtraSheetState extends State<AddExtraSheet> {
}

String _getExtraTitle(BuildContext context, ExtrasType? type) {
if (widget.isFiveSeven) {
return context.l10n.score_board_five_or_seven_text;
} else if (type == ExtrasType.noBall) {
if (type == ExtrasType.noBall) {
return "${context.l10n.score_board_no_ball_short_text} +";
} else if (type == ExtrasType.bye) {
return context.l10n.score_board_bye_text;
Expand Down
2 changes: 1 addition & 1 deletion khelo/lib/ui/flow/team/team_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class _TeamListScreenState extends ConsumerState<TeamListScreen>

return ListView.separated(
itemCount: state.filteredTeams.length,
padding: const EdgeInsets.all(16) + context.mediaQueryPadding,
padding: const EdgeInsets.symmetric(horizontal: 16) + context.mediaQueryPadding,
separatorBuilder: (context, index) =>
Divider(color: context.colorScheme.outline),
itemBuilder: (context, index) {
Expand Down

0 comments on commit a6616e8

Please sign in to comment.