Skip to content

Commit

Permalink
Update old designs to new (#111)
Browse files Browse the repository at this point in the history
* redesign add substitute

* adjust spacing

* add fielding tab

* remove deleted user from substitute

* use firstWhereOrNull for data

* minor change
  • Loading branch information
cp-sidhdhi-p authored Oct 4, 2024
1 parent b708615 commit fe43bb9
Show file tree
Hide file tree
Showing 58 changed files with 956 additions and 1,615 deletions.
25 changes: 0 additions & 25 deletions data/lib/service/ball_score/ball_score_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import '../../errors/app_error.dart';
import '../../extensions/double_extensions.dart';
import '../innings/inning_service.dart';
import '../match/match_service.dart';
import '../../storage/app_preferences.dart';
import '../../utils/constant/firestore_constant.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

Expand All @@ -16,16 +15,12 @@ final ballScoreServiceProvider = Provider((ref) {
FirebaseFirestore.instance,
ref.read(matchServiceProvider),
ref.read(inningServiceProvider),
ref.read(currentUserPod)?.id,
);

ref.listen(currentUserPod, (_, next) => service._currentUserId = next?.id);
return service;
});

class BallScoreService {
String? _currentUserId;

final FirebaseFirestore _firestore;
final MatchService _matchService;
final InningsService _inningsService;
Expand All @@ -34,7 +29,6 @@ class BallScoreService {
this._firestore,
this._matchService,
this._inningsService,
this._currentUserId,
);

CollectionReference<BallScoreModel> get _ballScoreCollection =>
Expand Down Expand Up @@ -135,25 +129,6 @@ class BallScoreService {
.handleError((error, stack) => throw AppError.fromError(error, stack));
}

Stream<List<BallScoreModel>> streamCurrentUserRelatedBalls() {
if (_currentUserId == null) {
return Stream.value([]);
}

return _ballScoreCollection
.where(
Filter.or(
Filter(FireStoreConst.bowlerId, isEqualTo: _currentUserId),
Filter(FireStoreConst.batsmanId, isEqualTo: _currentUserId),
Filter(FireStoreConst.wicketTakerId, isEqualTo: _currentUserId),
Filter(FireStoreConst.playerOutId, isEqualTo: _currentUserId),
),
)
.snapshots()
.map((event) => event.docs.map((score) => score.data()).toList())
.handleError((error, stack) => throw AppError.fromError(error, stack));
}

Future<void> deleteBallAndUpdateTeamDetails({
required String ballId,
required String matchId,
Expand Down
24 changes: 0 additions & 24 deletions data/lib/service/match/match_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,6 @@ class MatchService {
}
}

Stream<List<MatchModel>> streamCurrentUserPlayedMatches() {
if (_currentUserId == null) {
return Stream.value([]);
}

final filter = Filter.and(
Filter(FireStoreConst.matchStatus, isEqualTo: MatchStatus.finish.value),
Filter(FireStoreConst.players, arrayContains: _currentUserId),
);

return _matchCollection
.where(filter)
.snapshots()
.asyncMap((snapshot) async {
return await Future.wait(
snapshot.docs.map((mainDoc) async {
final match = mainDoc.data();
final List<MatchTeamModel> teams = await getTeamsList(match.teams);
return match.copyWith(teams: teams);
}).toList(),
);
}).handleError((error, stack) => throw AppError.fromError(error, stack));
}

Stream<List<MatchModel>> streamCurrentUserRelatedMatches() {
if (_currentUserId == null) {
return Stream.value([]);
Expand Down
14 changes: 5 additions & 9 deletions khelo/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"team_detail_add_members_title": "Add members",
"team_detail_add_match_title": "Add match",
"team_detail_make_admin": "Make admin",
"make_admin_selection_error": "Can't select deactivated user as admin",
"team_detail_make_admin_screen_title": "Make Admin",
"team_detail_admin": "{count, plural, =0{{count} admins} =1{{count} admin} other{{count} admins}}",
"@team_detail_admin": {
Expand Down Expand Up @@ -354,6 +355,7 @@
"user_detail_info_title": "Info",
"user_detail_batting_title": "Batting",
"user_detail_bowling_title": "Bowling",
"user_detail_fielding_title": "Fielding",
"user_detail_personal_information_title": "Personal information",
"user_detail_participation_title": "Participation",
"user_detail_role_title": "Role",
Expand All @@ -375,6 +377,9 @@
"user_detail_eco_title": "Eco",
"user_detail_no_ball_title": "NB",
"user_detail_wide_ball_title": "WB",
"user_detail_catches_title": "Catches",
"user_detail_run_out_title": "Run out",
"user_detail_stumping_title": "Stumping",

"match_status_yet_to_start_title": "Yet to start",
"match_status_running_title": "Running",
Expand Down Expand Up @@ -762,15 +767,6 @@
"@_STATS": {
},
"tab_stats_title": "Stats",
"my_stat_stats_batting_statics_title": "Batting Statistics",
"my_stat_stats_run_scored_title": "Run scored",
"my_stat_stats_strike_rate_title": "Strike rate",
"my_stat_stats_ball_faced_title": "Ball faced",
"my_stat_stats_bowling_statics_title": "Bowling Statistics",
"my_stat_stats_economy_rate_title": "Economy rate",
"my_stat_stats_fielding_statics_title": "Fielding Statistics",
"my_stat_stats_catches_title": "Catches",
"my_stat_stats_stumping_title": "Stumping",

"@_PROFILE": {
},
Expand Down
2 changes: 1 addition & 1 deletion khelo/lib/ui/flow/home/search/search_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class _SearchHomeScreenState extends ConsumerState<SearchHomeScreen> {
final match = matches[index - 1];
return MatchDetailCell(
match: match,
onTap: () => AppRoute.matchDetailTab(matchId: match.id),
onTap: () => AppRoute.matchDetailTab(matchId: match.id).push(context),
);
},
separatorBuilder: (context, index) => const SizedBox(height: 16),
Expand Down
41 changes: 22 additions & 19 deletions khelo/lib/ui/flow/home/view_all/home_view_all_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,27 @@ class _HomeViewAllScreenState extends ConsumerState<HomeViewAllScreen> {
);
}

return ListView.separated(
padding: const EdgeInsets.all(16) + context.mediaQueryPadding,
itemCount: state.matches.length + 1,
itemBuilder: (context, index) {
if (index < state.matches.length) {
final match = state.matches[index];
return MatchDetailCell(
match: match,
onTap: () =>
AppRoute.matchDetailTab(matchId: match.id).push(context),
);
}
return OnVisibleCallback(
onVisible: () => runPostFrame(() => notifier.loadMatches()),
child: (state.loading && state.matches.isNotEmpty)
? const Center(child: AppProgressIndicator())
: const SizedBox());
},
separatorBuilder: (context, index) => const SizedBox(height: 16));
return Padding(
padding: context.mediaQueryPadding,
child: ListView.separated(
padding: const EdgeInsets.all(16),
itemCount: state.matches.length + 1,
itemBuilder: (context, index) {
if (index < state.matches.length) {
final match = state.matches[index];
return MatchDetailCell(
match: match,
onTap: () =>
AppRoute.matchDetailTab(matchId: match.id).push(context),
);
}
return OnVisibleCallback(
onVisible: () => runPostFrame(() => notifier.loadMatches()),
child: (state.loading && state.matches.isNotEmpty)
? const Center(child: AppProgressIndicator())
: const SizedBox());
},
separatorBuilder: (context, index) => const SizedBox(height: 16)),
);
}
}
4 changes: 2 additions & 2 deletions khelo/lib/ui/flow/main/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:khelo/domain/extensions/context_extensions.dart';
import 'package:khelo/gen/assets.gen.dart';
import 'package:khelo/ui/flow/my_game/my_game_tab_screen.dart';
import 'package:khelo/ui/flow/profile/profile_screen.dart';
import 'package:khelo/ui/flow/stats/my_stats_tab_screen.dart';
import 'package:khelo/ui/flow/stats/user_stat/user_stat_screen.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:style/navigation/bottom_navigation_bar.dart';
Expand All @@ -31,7 +31,7 @@ class _MainScreenState extends ConsumerState<MainScreen>
static final List<Widget> _widgets = <Widget>[
const HomeScreen(),
const MyGameTabScreen(),
const MyStatsTabScreen(),
const UserStatScreen(),
const ProfileScreen(),
];

Expand Down
7 changes: 4 additions & 3 deletions khelo/lib/ui/flow/matches/add_match/add_match_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:data/api/match/match_model.dart';
import 'package:data/api/team/team_model.dart';
import 'package:data/service/match/match_service.dart';
Expand Down Expand Up @@ -134,9 +135,9 @@ class AddMatchViewNotifier extends StateNotifier<AddMatchViewState> {
.map((e) => e.user.id)
.toList();
final refereeId = state.officials
.where((element) => element.type == MatchOfficials.referee)
.map((e) => e.user.id)
.firstOrNull;
.firstWhereOrNull((element) => element.type == MatchOfficials.referee)
?.user
.id;

final firstSquad = state.squadA
?.map((e) => MatchPlayer(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:khelo/domain/extensions/context_extensions.dart';
Expand Down Expand Up @@ -32,8 +33,7 @@ class MatchOfficialSelectionView extends StatelessWidget {
type: official,
isWholeCellTappable: true,
user: state.officials
.where((element) => element.type == official)
.firstOrNull
.firstWhereOrNull((element) => element.type == official)
?.user,
onCardTap: () async {
final officials = await AppRoute.addMatchOfficials(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ class _AddMatchOfficialsScreenState
return Stack(
children: [
ListView(
padding: context.mediaQueryPadding + BottomStickyOverlay.padding,
padding: context.mediaQueryPadding +
BottomStickyOverlay.padding +
const EdgeInsets.only(bottom: 40),
children: [
for (final type in MatchOfficials.values) ...[
_sectionTitle(context, type.getTitle(context)),
_officialList(context, notifier, state, type),
],
const SizedBox(height: 40)
],
),
_stickyButton(context, state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ class SearchUserBottomSheet extends ConsumerWidget {
final notifier = ref.watch(searchUserStateProvider.notifier);
final state = ref.watch(searchUserStateProvider);

return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: SizedBox(
height: context.mediaQuerySize.height * 0.8,
return SizedBox(
height: context.mediaQuerySize.height * 0.8,
child: Padding(
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Column(
children: [
_searchTextField(context, notifier, state),
Expand Down Expand Up @@ -73,6 +74,7 @@ class SearchUserBottomSheet extends ConsumerWidget {
isShowButton: false,
)
: ListView.separated(
padding: const EdgeInsets.only(top: 16, bottom: 40),
separatorBuilder: (context, index) {
return Divider(
color: context.colorScheme.outline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ class _PowerPlayScreenState extends ConsumerState<PowerPlayScreen> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary),
Expanded(
child: Text(
title,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textPrimary),
),
),
OnTapScale(
onTap: onResetTap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ class _SelectSquadScreenState extends ConsumerState<SelectSquadScreen> {
)),
],
body: Builder(builder: (context) {
return ListView(
padding: context.mediaQueryPadding +
const EdgeInsets.symmetric(horizontal: 16),
children: [
_playingSquadList(context, notifier, state),
_teamMemberList(context, notifier, state)
],
return Padding(
padding: context.mediaQueryPadding,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16),
children: [
_playingSquadList(context, notifier, state),
_teamMemberList(context, notifier, state)
],
),
);
}),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:data/api/ball_score/ball_score_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -52,8 +53,7 @@ class CommentaryBallSummary extends StatelessWidget {

Widget _ballSummaryTextView(BuildContext context) {
final outPlayerSummary = overSummary.outPlayers
.where((element) => element.player.id == ball.player_out_id)
.firstOrNull;
.firstWhereOrNull((element) => element.player.id == ball.player_out_id);
final wicketTakerText = ball.wicket_type != null
? " ${ball.wicket_type?.getString(context)}${outPlayerSummary?.catchBy != null ? context.l10n.match_commentary_by_fielder_text(outPlayerSummary?.catchBy?.name ?? "") : ""}!!"
: "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:data/api/ball_score/ball_score_model.dart';
import 'package:data/api/team/team_model.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -109,8 +110,7 @@ class MatchDetailCommentaryView extends ConsumerWidget {

TeamModel? _getTeamByTeamId(MatchDetailTabState state, String teamId) {
return state.match?.teams
.where((element) => element.team.id == teamId)
.firstOrNull
.firstWhereOrNull((element) => element.team.id == teamId)
?.team;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:data/api/ball_score/ball_score_model.dart';
import 'package:data/api/match/match_model.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -163,8 +164,7 @@ class MatchDetailHighlightView extends ConsumerWidget {

String _getTeamNameByInningId(MatchDetailTabState state) {
final teamName = state.match?.teams
.where((element) => element.team.id == state.highlightTeamId)
.firstOrNull
.firstWhereOrNull((element) => element.team.id == state.highlightTeamId)
?.team
.name;
return teamName ?? "--";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:data/api/match/match_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -120,8 +121,7 @@ class MatchDetailInfoView extends ConsumerWidget {

Widget _tossDetailView(BuildContext context, MatchModel match) {
String? teamName = match.teams
.where((element) => element.team.id == match.toss_winner_id)
.firstOrNull
.firstWhereOrNull((element) => element.team.id == match.toss_winner_id)
?.team
.name;
String? decision = match.toss_decision?.getString(context);
Expand Down
Loading

0 comments on commit fe43bb9

Please sign in to comment.