Skip to content

Commit 05636bb

Browse files
committed
Subteams view in team's profile. Jumpers rankings. Empty states.
1 parent 5f21b97 commit 05636bb

10 files changed

+228
-27
lines changed

lib/models/simulation/database/actions/simulation_actions_repo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SimulationActionsRepo with EquatableMixin {
2828
return _completedActions.contains(action);
2929
}
3030

31-
bool isIncompleted(SimulationActionType action) => !isCompleted(action);
31+
bool isNotCompleted(SimulationActionType action) => !isCompleted(action);
3232

3333
@override
3434
List<Object?> get props => [

lib/ui/screens/simulation/large/__top_panel.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class _TopPanel extends StatelessWidget {
1212
final database = context.watch<SimulationDatabaseCubit>().state;
1313
/*final availableActions = possibleActionsBySimulationMode[database.managerData.mode]!;*/ // TODO!!
1414
const availableActions = SimulationActionType.values;
15-
final incompletedActions = availableActions.where(database.actionsRepo.isIncompleted);
15+
final incompletedActions =
16+
availableActions.where(database.actionsRepo.isNotCompleted);
1617
final sortedIncompletedActions = incompletedActions.sorted(
1718
(first, second) {
1819
return database.actionDeadlines[second]!

lib/ui/screens/simulation/large/subscreens/__teams_screen.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,19 @@ class _ListView extends StatelessWidget {
154154
onTap: () async {
155155
final team = teams.elementAt(index);
156156
final flagsRepo = context.read<CountryFlagsRepo>();
157+
final jumperImagesRepo = context.read<DbItemImageGeneratingSetup<Jumper>>();
158+
final databaseCubit = context.read<SimulationDatabaseCubit>();
159+
final dbHelper = context.read<SimulationDatabaseHelper>();
157160
await showDialog(
158161
context: context,
159162
builder: (context) {
160163
return BlocProvider.value(
161-
value: context.read<SimulationDatabaseCubit>(),
164+
value: databaseCubit,
162165
child: MultiProvider(
163166
providers: [
164167
Provider.value(value: flagsRepo),
168+
Provider.value(value: jumperImagesRepo),
169+
Provider.value(value: dbHelper),
165170
],
166171
child: Center(
167172
child: ClipRRect(

lib/ui/screens/simulation/large/widgets/__upcoming_simulation_action_card.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ class _UpcomingSimulationActionCard extends StatelessWidget {
1919
SimulationActionType.settingUpTraining => translator.settingUpTraining,
2020
SimulationActionType.settingUpSubteams => translator.settingUpSubteams,
2121
};
22-
print('current date: ${database.currentDate}');
23-
print('deadlines: ${database.actionDeadlines}');
2422
final dateText = sjmFutureDateDescription(
2523
context: context,
2624
currentDate: database.currentDate,

lib/ui/screens/simulation/large/widgets/teams/country_team_profile/country_team_profile_widget.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:material_symbols_icons/material_symbols_icons.dart';
44
import 'package:sj_manager/models/user_db/team/country_team/country_team.dart';
55
import 'package:sj_manager/ui/reusable_widgets/countries/country_flag.dart';
66
import 'package:sj_manager/ui/screens/simulation/large/widgets/teams/country_team_profile/overview/country_team_profile_overview.dart';
7+
import 'package:sj_manager/ui/screens/simulation/large/widgets/teams/country_team_profile/subteams/country_team_profile_subteams.dart';
78
import 'package:sj_manager/utils/icons.dart';
89

910
class CountryTeamProfileWidget extends StatefulWidget {
@@ -68,7 +69,9 @@ class _CountryTeamProfileWidgetState extends State<CountryTeamProfileWidget> {
6869
CountryTeamProfileOverview(
6970
countryTeam: widget.team,
7071
),
71-
const Placeholder(),
72+
CountryTeamProfileSubteams(
73+
countryTeam: widget.team,
74+
),
7275
const Placeholder(),
7376
],
7477
),

lib/ui/screens/simulation/large/widgets/teams/country_team_profile/overview/country_team_profile_overview.dart

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
3+
import 'package:gap/gap.dart';
34
import 'package:sj_manager/algorithms/jumpers_ranking/country_team_ranking_creator.dart';
45
import 'package:sj_manager/bloc/simulation/simulation_database_cubit.dart';
5-
import 'package:sj_manager/models/user_db/jumper/jumper.dart';
66
import 'package:sj_manager/models/user_db/team/country_team/country_team.dart';
77
import 'package:sj_manager/ui/reusable_widgets/card_with_title.dart';
88
import 'package:sj_manager/ui/reusable_widgets/jumpers_ranking/team_jumpers_ranking_list.dart';
@@ -18,39 +18,84 @@ class CountryTeamProfileOverview extends StatelessWidget {
1818
@override
1919
Widget build(BuildContext context) {
2020
final database = context.watch<SimulationDatabaseCubit>().state;
21-
final subteams = database.subteamJumpers.keys.where(
22-
(subteam) => subteam.parentTeam == countryTeam,
23-
);
24-
final unorderedJumpers = <Jumper>[];
25-
for (var subteam in subteams) {
26-
final jumperIds = database.subteamJumpers[subteam]!;
27-
unorderedJumpers.addAll(
28-
jumperIds.map((id) => database.idsRepo.get(id) as Jumper),
29-
);
30-
}
21+
final unorderedJumpers = database.jumpers.last.where((jumper) =>
22+
jumper.country == countryTeam.country && jumper.sex == countryTeam.sex);
23+
3124
final ranking = CountryTeamRankingCreator(
32-
jumpers: unorderedJumpers, dynamicParams: database.jumperDynamicParams)
25+
jumpers: unorderedJumpers.toList(),
26+
dynamicParams: database.jumperDynamicParams)
3327
.create();
3428

3529
return Row(
3630
children: [
3731
SizedBox(
38-
width: 250,
39-
child: CardWithTitle(
40-
title: Text(
41-
'Ranking',
42-
style: Theme.of(context).textTheme.headlineSmall,
43-
),
44-
child: TeamJumpersRankingList(
45-
jumpers: ranking,
46-
),
32+
width: 350,
33+
child: Column(
34+
crossAxisAlignment: CrossAxisAlignment.stretch,
35+
children: [
36+
SizedBox(
37+
height: 200,
38+
child: CardWithTitle(
39+
color: Theme.of(context).colorScheme.surfaceContainer,
40+
title: Text(
41+
'Ranking',
42+
style: Theme.of(context).textTheme.headlineSmall,
43+
),
44+
child: ranking.isNotEmpty
45+
? TeamJumpersRankingList(
46+
jumpers: ranking,
47+
)
48+
: const Center(
49+
child: Text('Brak zawodników'),
50+
),
51+
),
52+
),
53+
const Gap(10),
54+
Expanded(
55+
child: CardWithTitle(
56+
color: Theme.of(context).colorScheme.surfaceContainer,
57+
title: Text(
58+
'Informacje',
59+
style: Theme.of(context).textTheme.headlineSmall,
60+
),
61+
child: const SizedBox.expand(
62+
child: Placeholder(
63+
child: Center(child: Text('Jeszcze nie dodano...')),
64+
),
65+
),
66+
),
67+
),
68+
],
4769
),
4870
)
4971
],
5072
);
5173
}
5274
}
5375

76+
class _DataRow extends StatelessWidget {
77+
const _DataRow({
78+
required this.titleText,
79+
required this.right,
80+
});
81+
82+
final String titleText;
83+
final Widget right;
84+
85+
@override
86+
Widget build(BuildContext context) {
87+
return Row(
88+
children: [
89+
Text(
90+
titleText,
91+
style: Theme.of(context).textTheme.titleSmall,
92+
),
93+
right,
94+
],
95+
);
96+
}
97+
}
98+
5499
// ranking skoczków
55100
// perspektywa
56101
// podstawowe rekordy (wygranych konkursow druż pś, wygranych konkursów ind pś)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import 'package:collection/collection.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_bloc/flutter_bloc.dart';
4+
import 'package:sj_manager/bloc/simulation/simulation_database_cubit.dart';
5+
import 'package:sj_manager/models/simulation/database/actions/simulation_action_type.dart';
6+
import 'package:sj_manager/models/user_db/jumper/jumper.dart';
7+
import 'package:sj_manager/models/user_db/team/country_team/country_team.dart';
8+
import 'package:sj_manager/ui/screens/simulation/large/widgets/teams/country_team_profile/subteams/country_team_profile_subteams_not_available.dart';
9+
import 'package:sj_manager/ui/screens/simulation/large/widgets/teams/country_team_profile/subteams/country_team_profile_subteams_non_empty.dart';
10+
11+
class CountryTeamProfileSubteams extends StatelessWidget {
12+
const CountryTeamProfileSubteams({
13+
super.key,
14+
required this.countryTeam,
15+
});
16+
17+
final CountryTeam countryTeam;
18+
19+
@override
20+
Widget build(BuildContext context) {
21+
final database = context.watch<SimulationDatabaseCubit>().state;
22+
final subteams = database.subteamJumpers.keys
23+
.where((subteam) => subteam.parentTeam == countryTeam)
24+
..sorted((first, second) => first.type.index.compareTo(second.type.index));
25+
if (subteams.isEmpty &&
26+
database.actionsRepo.isNotCompleted(SimulationActionType.settingUpSubteams)) {
27+
return CountryTeamProfileSubteamsNotAvailable(
28+
currentDate: database.currentDate,
29+
settingUpSubteamsDeadline:
30+
database.actionDeadlines[SimulationActionType.settingUpSubteams]!,
31+
);
32+
} else if (subteams.isEmpty &&
33+
database.actionsRepo.isCompleted(SimulationActionType.settingUpSubteams)) {
34+
return Center(
35+
child: Text(
36+
'Brak zawodników w drużynie',
37+
style: Theme.of(context).textTheme.bodyLarge,
38+
),
39+
);
40+
} else {
41+
return CountryTeamProfileSubteamsNonEmpty(
42+
subteams: subteams.toList(),
43+
jumpers: database.subteamJumpers.map(
44+
(subteam, ids) => MapEntry(
45+
subteam,
46+
ids.map((id) => database.idsRepo.get(id) as Jumper).toList(),
47+
),
48+
),
49+
);
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:gap/gap.dart';
3+
import 'package:sj_manager/models/user_db/jumper/jumper.dart';
4+
import 'package:sj_manager/models/user_db/team/subteam.dart';
5+
import 'package:sj_manager/ui/screens/simulation/large/widgets/team/jumper/jumper_simple_list_tile.dart';
6+
import 'package:sj_manager/ui/screens/simulation/utils/jumper_ratings_translations.dart';
7+
8+
class CountryTeamProfileSubteamsNonEmpty extends StatelessWidget {
9+
const CountryTeamProfileSubteamsNonEmpty({
10+
super.key,
11+
required this.subteams,
12+
required this.jumpers,
13+
});
14+
15+
final List<Subteam> subteams;
16+
final Map<Subteam, List<Jumper>> jumpers;
17+
18+
@override
19+
Widget build(BuildContext context) {
20+
return ListView(
21+
scrollDirection: Axis.horizontal,
22+
children: [
23+
for (final subteam in subteams)
24+
Column(
25+
children: [
26+
Text(
27+
translateJumperSubteamType(context: context, subteamType: subteam.type),
28+
style: Theme.of(context).textTheme.titleLarge,
29+
),
30+
const Gap(10),
31+
Expanded(
32+
child: SizedBox(
33+
width: 350,
34+
child: ListView.separated(
35+
scrollDirection: Axis.vertical,
36+
itemCount: jumpers[subteam]!.length,
37+
itemBuilder: (context, index) => JumperSimpleListTile(
38+
jumper: jumpers[subteam]![index],
39+
subtitle: JumperSimpleListTileSubtitle.none,
40+
),
41+
separatorBuilder: (context, index) => const Gap(10),
42+
),
43+
),
44+
),
45+
],
46+
),
47+
],
48+
);
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:intl/intl.dart';
3+
import 'package:sj_manager/utils/translating.dart';
4+
5+
class CountryTeamProfileSubteamsNotAvailable extends StatelessWidget {
6+
const CountryTeamProfileSubteamsNotAvailable({
7+
super.key,
8+
required this.currentDate,
9+
required this.settingUpSubteamsDeadline,
10+
});
11+
12+
final DateTime currentDate;
13+
final DateTime settingUpSubteamsDeadline;
14+
15+
static final dateFormat = DateFormat("d MMM");
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
final futureDateText = sjmFutureDateDescription(
20+
context: context,
21+
currentDate: currentDate,
22+
targetDate: settingUpSubteamsDeadline,
23+
).toLowerCase();
24+
return Center(
25+
child: Text.rich(
26+
TextSpan(
27+
children: [
28+
TextSpan(
29+
text: 'Ustalone kadry pojawią się ',
30+
style: Theme.of(context).textTheme.bodyMedium,
31+
),
32+
TextSpan(
33+
text: futureDateText,
34+
style: Theme.of(context).textTheme.titleSmall,
35+
),
36+
TextSpan(
37+
text: ' (${dateFormat.format(settingUpSubteamsDeadline)})',
38+
style: Theme.of(context).textTheme.bodyMedium,
39+
),
40+
],
41+
),
42+
),
43+
);
44+
}
45+
}

lib/ui/screens/simulation/simulation_route.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:sj_manager/l10n/helpers.dart';
1818
import 'package:sj_manager/models/simulation/database/actions/simulation_action_type.dart';
1919
import 'package:sj_manager/models/simulation/database/helper/simulation_database_helper.dart';
2020
import 'package:sj_manager/models/simulation/flow/simulation_mode.dart';
21+
import 'package:sj_manager/models/user_db/jumper/jumper.dart';
2122
import 'package:sj_manager/models/user_db/sex.dart';
2223
import 'package:sj_manager/repositories/countries/countries_repo.dart';
2324
import 'package:sj_manager/repositories/countries/country_flags/country_flags_repo.dart';
@@ -26,6 +27,7 @@ import 'package:sj_manager/ui/responsiveness/responsive_builder.dart';
2627
import 'package:sj_manager/ui/reusable_widgets/card_with_title.dart';
2728
import 'package:sj_manager/ui/reusable_widgets/countries/country_flag.dart';
2829
import 'package:provider/provider.dart';
30+
import 'package:sj_manager/ui/reusable_widgets/database_item_images/db_item_image_generating_setup.dart';
2931
import 'package:sj_manager/ui/reusable_widgets/link_text_button.dart';
3032
import 'package:sj_manager/ui/screens/simulation/large/dialogs/subteams_setting_up_help_dialog.dart';
3133
import 'package:sj_manager/ui/screens/simulation/large/dialogs/training_tutorial_dialog.dart';

0 commit comments

Comments
 (0)