Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove group option conditionally #138

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions data/lib/service/ball_score/ball_score_service.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import 'dart:async';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../api/ball_score/ball_score_model.dart';
import '../../api/match/match_model.dart';
import '../../errors/app_error.dart';
import '../../extensions/double_extensions.dart';
import '../../extensions/list_extensions.dart';
import '../../utils/constant/firestore_constant.dart';
import '../innings/inning_service.dart';
import '../match/match_service.dart';
import '../../utils/constant/firestore_constant.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../api/match/match_model.dart';

final ballScoreServiceProvider = Provider((ref) {
final service = BallScoreService(
Expand Down Expand Up @@ -105,10 +107,15 @@ class BallScoreService {
) async {
try {
if (matchIds.isEmpty) return [];
final ballScoreRef = await _ballScoreCollection
.where(FireStoreConst.matchId, whereIn: matchIds)
.get();
return ballScoreRef.docs.map((e) => e.data()).toList();
final List<BallScoreModel> data = [];
for (var ids in matchIds.chunked(30)) {
final ballScoreRef = await _ballScoreCollection
.where(FireStoreConst.matchId, whereIn: ids)
.get();
data.addAll(ballScoreRef.docs.map((e) => e.data()));
}

return data;
} catch (error, stack) {
throw AppError.fromError(error, stack);
}
Expand Down
1 change: 1 addition & 0 deletions khelo/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@
"score_board_inning_complete_title": "Inning complete",
"score_board_match_complete_title": "Match complete",
"score_board_match_tied_text": "The match has been tied",
"score_board_match_tied": "Match tied",
"score_board_start_next_inning_title": "Start Next Inning",
"score_board_end_inning_title": "End Inning",
"score_board_current_team_title": "Current Team",
Expand Down
6 changes: 5 additions & 1 deletion khelo/lib/components/won_by_message_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class WonByMessageText extends StatelessWidget {
return const SizedBox();
}
if (matchResult!.winType == WinnerByType.tie) {
return Text(context.l10n.score_board_match_tied_text,
return Text(
isTournament
? context.l10n.score_board_match_tied
: context.l10n.score_board_match_tied_text,
textAlign: isTournament ? TextAlign.center : TextAlign.left,
style: textStyle ??
AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary));
Expand Down
31 changes: 22 additions & 9 deletions khelo/lib/ui/flow/home/components/tournament_item.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';

import 'package:data/api/tournament/tournament_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
Expand Down Expand Up @@ -32,23 +31,37 @@ class TournamentItem extends StatefulWidget {
}

class _TournamentItemState extends State<TournamentItem> {
late ImageProvider imageProvider;
ImageProvider? imageProvider;

PaletteGenerator? palette;

@override
void initState() {
super.initState();
if (widget.tournament.banner_img_url != null) {
imageProvider =
CachedNetworkImageProvider(widget.tournament.banner_img_url!);
_initializeImageProvider(widget.tournament.banner_img_url);
}

void _initializeImageProvider(String? imageUrl) {
if (imageUrl != null) {
imageProvider = CachedNetworkImageProvider(imageUrl);
if (widget.background == null) {
imageProvider.createPaletteGenerator().then((palette) {
imageProvider!.createPaletteGenerator().then((generatedPalette) {
if (mounted) {
setState(() => this.palette = palette);
setState(() => palette = generatedPalette);
}
});
}
} else {
setState(() => imageProvider = null);
}
}

@override
void didUpdateWidget(covariant TournamentItem oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.tournament.banner_img_url !=
oldWidget.tournament.banner_img_url) {
_initializeImageProvider(widget.tournament.banner_img_url);
}
}

Expand Down Expand Up @@ -101,10 +114,10 @@ class _TournamentItemState extends State<TournamentItem> {
decoration: BoxDecoration(
color: context.colorScheme.containerNormalOnSurface,
borderRadius: BorderRadius.circular(8),
image: bannerUrl == null
image: bannerUrl == null || imageProvider == null
? null
: DecorationImage(
image: imageProvider,
image: imageProvider!,
fit: BoxFit.fill,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ class EditProfileScreen extends ConsumerWidget {
context,
helpText: context.l10n.edit_profile_select_birth_date_placeholder,
initialDate: state.dob,
startDate: DateTime(1950),
endDate: DateTime.now(),
onDateSelected: (date) {
if (date != state.dob) {
notifier.onDateSelect(selectedDate: date);
Expand Down
2 changes: 2 additions & 0 deletions khelo/lib/ui/flow/tournament/add/add_tournament_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class _AddTournamentScreenState extends ConsumerState<AddTournamentScreen> {
onTap: () {
selectDate(
context,
startDate: widget.editTournament?.start_date,
initialDate: state.startDate,
onDateSelected: notifier.onStartDate,
);
Expand All @@ -377,6 +378,7 @@ class _AddTournamentScreenState extends ConsumerState<AddTournamentScreen> {
onTap: () {
selectDate(
context,
startDate: widget.editTournament?.start_date,
initialDate: state.endDate,
onDateSelected: notifier.onEndDate,
);
Expand Down
18 changes: 16 additions & 2 deletions khelo/lib/ui/flow/tournament/add/add_tournament_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,26 @@ class AddTournamentViewNotifier extends StateNotifier<AddTournamentState> {
}

void onStartDate(DateTime startDate) {
state = state.copyWith(startDate: startDate);
DateTime endDate = state.endDate;

if (startDate.isAfter(endDate)) {
endDate = startDate.add(Duration(days: 1));
}
state = state.copyWith(startDate: startDate, endDate: endDate);
onChange();
}

void onEndDate(DateTime endDate) {
state = state.copyWith(endDate: endDate);
DateTime startDate = state.startDate;

if (endDate.isBefore(startDate)) {
startDate = endDate.subtract(Duration(days: 1));
if (_editedTournament != null &&
startDate.isBefore(_editedTournament!.start_date)) {
startDate = _editedTournament!.start_date;
}
}
state = state.copyWith(endDate: endDate, startDate: startDate);
onChange();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ class FilterTabView extends StatelessWidget {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: AppTextStyle.header4.copyWith(
color: context.colorScheme.textPrimary,
Expanded(
child: Text(
title,
style: AppTextStyle.header4.copyWith(
color: context.colorScheme.textPrimary,
),
),
),
TextButton.icon(
Expand Down
26 changes: 20 additions & 6 deletions khelo/lib/ui/flow/tournament/detail/components/flexible_space.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,35 @@ class FlexibleSpace extends StatefulWidget {
}

class _FlexibleSpaceState extends State<FlexibleSpace> {
late ImageProvider imageProvider;
ImageProvider? imageProvider;

PaletteGenerator? palette;

@override
void initState() {
super.initState();
if (widget.tournament.banner_img_url != null) {
imageProvider =
CachedNetworkImageProvider(widget.tournament.banner_img_url!);
imageProvider.createPaletteGenerator().then((palette) {
_initializeImageProvider(widget.tournament.banner_img_url);
}

@override
void didUpdateWidget(covariant FlexibleSpace oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.tournament.banner_img_url !=
oldWidget.tournament.banner_img_url) {
_initializeImageProvider(widget.tournament.banner_img_url);
}
}

void _initializeImageProvider(String? imageUrl) {
if (imageUrl != null) {
imageProvider = CachedNetworkImageProvider(imageUrl);
imageProvider!.createPaletteGenerator().then((generatedPalette) {
if (mounted) {
setState(() => this.palette = palette);
setState(() => palette = generatedPalette);
}
});
} else {
setState(() => imageProvider = null);
}
}

Expand Down
Loading
Loading