Skip to content

Commit

Permalink
[Presentation] Added the team section
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jan 19, 2022
1 parent e92ec9c commit eb31aee
Show file tree
Hide file tree
Showing 9 changed files with 509 additions and 110 deletions.
137 changes: 96 additions & 41 deletions lib/presentation/custom_build/custom_build_page.dart
Expand Up @@ -13,6 +13,7 @@ import 'package:shiori/generated/l10n.dart';
import 'package:shiori/injection.dart';
import 'package:shiori/presentation/custom_build/widgets/artifact_section.dart';
import 'package:shiori/presentation/custom_build/widgets/character_section.dart';
import 'package:shiori/presentation/custom_build/widgets/team_section.dart';
import 'package:shiori/presentation/custom_build/widgets/weapon_section.dart';
import 'package:shiori/presentation/shared/extensions/element_type_extensions.dart';
import 'package:shiori/presentation/shared/loading.dart';
Expand Down Expand Up @@ -78,11 +79,12 @@ class _PageState extends State<_Page> {
character: state.character,
weapons: state.weapons,
artifacts: state.artifacts,
teamCharacters: state.teamCharacters,
notes: state.notes,
skillPriorities: state.skillPriorities,
subStatsSummary: state.subStatsSummary,
),
landscape: (context) => width > 700
landscape: (context) => width > 1280
? _LandscapeLayout(
title: state.title.isNullEmptyOrWhitespace ? s.dps : state.title,
roleType: state.type,
Expand All @@ -92,6 +94,7 @@ class _PageState extends State<_Page> {
character: state.character,
weapons: state.weapons,
artifacts: state.artifacts,
teamCharacters: state.teamCharacters,
notes: state.notes,
skillPriorities: state.skillPriorities,
subStatsSummary: state.subStatsSummary,
Expand All @@ -105,6 +108,7 @@ class _PageState extends State<_Page> {
character: state.character,
weapons: state.weapons,
artifacts: state.artifacts,
teamCharacters: state.teamCharacters,
notes: state.notes,
skillPriorities: state.skillPriorities,
subStatsSummary: state.subStatsSummary,
Expand Down Expand Up @@ -186,8 +190,9 @@ class _PortraitLayout extends StatelessWidget {
final bool showOnCharacterDetail;
final bool isRecommended;
final CharacterCardModel character;
final List<WeaponCardModel> weapons;
final List<CustomBuildWeaponModel> weapons;
final List<CustomBuildArtifactModel> artifacts;
final List<CustomBuildTeamCharacterModel> teamCharacters;
final List<CustomBuildNoteModel> notes;
final List<CharacterSkillType> skillPriorities;
final List<StatType> subStatsSummary;
Expand All @@ -202,6 +207,7 @@ class _PortraitLayout extends StatelessWidget {
required this.character,
required this.weapons,
required this.artifacts,
required this.teamCharacters,
required this.notes,
required this.skillPriorities,
required this.subStatsSummary,
Expand All @@ -225,22 +231,31 @@ class _PortraitLayout extends StatelessWidget {
),
ScreenTypeLayout.builder(
desktop: (context) => _WeaponsAndArtifacts(
elementType: character.elementType,
mainCharKey: character.key,
weaponType: character.weaponType,
color: character.elementType.getElementColorFromContext(context),
weapons: weapons,
artifacts: artifacts,
teamCharacters: teamCharacters,
subStatsSummary: subStatsSummary,
),
tablet: (context) => _WeaponsAndArtifacts(
elementType: character.elementType,
mainCharKey: character.key,
weaponType: character.weaponType,
color: character.elementType.getElementColorFromContext(context),
weapons: weapons,
artifacts: artifacts,
teamCharacters: teamCharacters,
subStatsSummary: subStatsSummary,
),
mobile: (context) => _WeaponsAndArtifacts(
useColumn: isPortrait,
elementType: character.elementType,
mainCharKey: character.key,
weaponType: character.weaponType,
color: character.elementType.getElementColorFromContext(context),
weapons: weapons,
artifacts: artifacts,
teamCharacters: teamCharacters,
subStatsSummary: subStatsSummary,
),
),
Expand All @@ -256,8 +271,9 @@ class _LandscapeLayout extends StatelessWidget {
final bool showOnCharacterDetail;
final bool isRecommended;
final CharacterCardModel character;
final List<WeaponCardModel> weapons;
final List<CustomBuildWeaponModel> weapons;
final List<CustomBuildArtifactModel> artifacts;
final List<CustomBuildTeamCharacterModel> teamCharacters;
final List<CustomBuildNoteModel> notes;
final List<CharacterSkillType> skillPriorities;
final List<StatType> subStatsSummary;
Expand All @@ -272,6 +288,7 @@ class _LandscapeLayout extends StatelessWidget {
required this.character,
required this.weapons,
required this.artifacts,
required this.teamCharacters,
required this.notes,
required this.skillPriorities,
required this.subStatsSummary,
Expand All @@ -297,20 +314,35 @@ class _LandscapeLayout extends StatelessWidget {
),
),
Expanded(
flex: 30,
child: WeaponSection(
weapons: weapons,
color: character.elementType.getElementColorFromContext(context),
maxItemImageWidth: _maxItemImageWidth,
),
),
Expanded(
flex: 30,
child: ArtifactSection(
artifacts: artifacts,
color: character.elementType.getElementColorFromContext(context),
maxItemImageWidth: _maxItemImageWidth,
subStatsSummary: subStatsSummary,
flex: 60,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: WeaponSection(
weapons: weapons,
weaponType: character.weaponType,
color: character.elementType.getElementColorFromContext(context),
maxItemImageWidth: _maxItemImageWidth,
),
),
Expanded(
child: ArtifactSection(
artifacts: artifacts,
color: character.elementType.getElementColorFromContext(context),
maxItemImageWidth: _maxItemImageWidth,
subStatsSummary: subStatsSummary,
),
),
Expanded(
child: TeamSection(
mainCharKey: character.key,
teamCharacters: teamCharacters,
color: character.elementType.getElementColorFromContext(context),
),
),
],
),
),
],
Expand All @@ -319,19 +351,25 @@ class _LandscapeLayout extends StatelessWidget {
}

class _WeaponsAndArtifacts extends StatelessWidget {
final ElementType elementType;
final List<WeaponCardModel> weapons;
final String mainCharKey;
final WeaponType weaponType;
final List<CustomBuildWeaponModel> weapons;
final List<CustomBuildArtifactModel> artifacts;
final List<CustomBuildTeamCharacterModel> teamCharacters;
final bool useColumn;
final List<StatType> subStatsSummary;
final Color color;

const _WeaponsAndArtifacts({
Key? key,
required this.elementType,
required this.mainCharKey,
required this.weaponType,
required this.weapons,
required this.artifacts,
required this.teamCharacters,
this.useColumn = false,
required this.subStatsSummary,
required this.color,
}) : super(key: key);

@override
Expand All @@ -341,36 +379,53 @@ class _WeaponsAndArtifacts extends StatelessWidget {
children: [
WeaponSection(
weapons: weapons,
color: elementType.getElementColorFromContext(context),
weaponType: weaponType,
color: color,
maxItemImageWidth: _maxItemImageWidth,
),
ArtifactSection(
artifacts: artifacts,
color: elementType.getElementColorFromContext(context),
color: color,
maxItemImageWidth: _maxItemImageWidth,
subStatsSummary: subStatsSummary,
),
TeamSection(
mainCharKey: mainCharKey,
teamCharacters: teamCharacters,
color: color,
),
],
);
}
return Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: WeaponSection(
weapons: weapons,
color: elementType.getElementColorFromContext(context),
maxItemImageWidth: _maxItemImageWidth,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: WeaponSection(
weapons: weapons,
weaponType: weaponType,
color: color,
maxItemImageWidth: _maxItemImageWidth,
),
),
Expanded(
child: ArtifactSection(
artifacts: artifacts,
color: color,
maxItemImageWidth: _maxItemImageWidth,
subStatsSummary: subStatsSummary,
),
),
],
),
Expanded(
child: ArtifactSection(
artifacts: artifacts,
color: elementType.getElementColorFromContext(context),
maxItemImageWidth: _maxItemImageWidth,
subStatsSummary: subStatsSummary,
),
TeamSection(
mainCharKey: mainCharKey,
teamCharacters: teamCharacters,
color: color,
),
],
);
Expand Down
26 changes: 13 additions & 13 deletions lib/presentation/custom_build/widgets/artifact_row.dart
Expand Up @@ -15,7 +15,7 @@ import 'package:shiori/presentation/shared/item_popupmenu_filter.dart';
import 'package:shiori/presentation/shared/styles.dart';
import 'package:shiori/presentation/shared/sub_stats_to_focus.dart';

enum _ArtifactOptions {
enum _Options {
subStats,
delete,
update,
Expand Down Expand Up @@ -79,21 +79,21 @@ class ArtifactRow extends StatelessWidget {
),
),
),
ItemPopupMenuFilter<_ArtifactOptions>.withoutSelectedValue(
values: _ArtifactOptions.values,
ItemPopupMenuFilter<_Options>.withoutSelectedValue(
values: _Options.values,
tooltipText: s.options,
icon: const Icon(Icons.more_vert),
onSelected: (type) => _handleOptionSelected(context, type),
childBuilder: (e) {
Widget icon;
switch (e.enumValue) {
case _ArtifactOptions.subStats:
case _Options.subStats:
icon = const Icon(Icons.menu);
break;
case _ArtifactOptions.delete:
case _Options.delete:
icon = const Icon(Icons.delete);
break;
case _ArtifactOptions.update:
case _Options.update:
icon = const Icon(Icons.edit);
break;
default:
Expand All @@ -112,11 +112,11 @@ class ArtifactRow extends StatelessWidget {
},
itemText: (type, _) {
switch (type) {
case _ArtifactOptions.subStats:
case _Options.subStats:
return s.subStats;
case _ArtifactOptions.delete:
case _Options.delete:
return s.delete;
case _ArtifactOptions.update:
case _Options.update:
return s.update;
default:
throw Exception('The provided artifact option type = $type is not valid');
Expand All @@ -127,10 +127,10 @@ class ArtifactRow extends StatelessWidget {
);
}

Future<void> _handleOptionSelected(BuildContext context, _ArtifactOptions option) async {
Future<void> _handleOptionSelected(BuildContext context, _Options option) async {
final bloc = context.read<CustomBuildBloc>();
switch (option) {
case _ArtifactOptions.subStats:
case _Options.subStats:
await showDialog(
context: context,
builder: (_) => BlocProvider.value(
Expand All @@ -144,10 +144,10 @@ class ArtifactRow extends StatelessWidget {
),
);
break;
case _ArtifactOptions.delete:
case _Options.delete:
bloc.add(CustomBuildEvent.deleteArtifact(type: artifact.type));
break;
case _ArtifactOptions.update:
case _Options.update:
StatType? statType;
switch (artifact.type) {
case ArtifactType.flower:
Expand Down
8 changes: 5 additions & 3 deletions lib/presentation/custom_build/widgets/artifact_section.dart
Expand Up @@ -46,7 +46,7 @@ class ArtifactSection extends StatelessWidget {
border: isPortrait ? Border(top: BorderSide(color: Colors.white)) : null,
),
child: Text(
s.artifacts,
'${s.artifacts} (${artifacts.length} / ${ArtifactType.values.length})',
textAlign: TextAlign.center,
style: theme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.bold),
),
Expand Down Expand Up @@ -74,8 +74,10 @@ class ArtifactSection extends StatelessWidget {
),
],
),
if (artifacts.isEmpty) NothingFound(msg: s.startByAddingArtifacts),
...artifacts.map((e) => ArtifactRow(artifact: e, color: color, maxImageWidth: maxItemImageWidth)),
if (artifacts.isEmpty)
NothingFound(msg: s.startByAddingArtifacts)
else
...artifacts.map((e) => ArtifactRow(artifact: e, color: color, maxImageWidth: maxItemImageWidth)),
if (subStatsSummary.isNotEmpty)
SubStatToFocus(
subStatsToFocus: subStatsSummary,
Expand Down

0 comments on commit eb31aee

Please sign in to comment.