Skip to content

Commit

Permalink
The note in the artifacts page now shows some images
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jan 18, 2021
1 parent 3c5a3f4 commit 330ba74
Show file tree
Hide file tree
Showing 21 changed files with 374 additions and 251 deletions.
22 changes: 22 additions & 0 deletions lib/common/assets.dart
Expand Up @@ -2,6 +2,7 @@ import 'enums/app_language_type.dart';
import 'enums/element_type.dart';
import 'enums/material_type.dart';
import 'enums/weapon_type.dart';
import 'enums/artifact_type.dart';

class Assets {
static String dbPath = 'assets/db';
Expand Down Expand Up @@ -37,6 +38,7 @@ class Assets {
static String weaponBasePath = '$itemsBasePath/weapon';
static String weaponPrimaryBasePath = '$itemsBasePath/weapon_primary';
static String currencyBasePath = '$itemsBasePath/currency';
static String othersBasePath = '$itemsBasePath/others';

static String getArtifactPath(String name) => '$artifactsBasePath/$name';
static String getCharacterPath(String name) => '$charactersBasePath/$name';
Expand All @@ -57,6 +59,7 @@ class Assets {
static String getWeaponMaterialPath(String name) => '$weaponBasePath/$name';
static String getWeaponPrimaryMaterialPath(String name) => '$weaponPrimaryBasePath/$name';
static String getCurrencyMaterialPath(String name) => '$currencyBasePath/$name';
static String getOtherMaterialPath(String name) => '$othersBasePath/$name';

static String getMaterialPath(String name, MaterialType type) {
switch (type) {
Expand All @@ -76,6 +79,8 @@ class Assets {
return getWeaponMaterialPath(name);
case MaterialType.weaponPrimary:
return getWeaponPrimaryMaterialPath(name);
case MaterialType.others:
return getOtherMaterialPath(name);
default:
throw Exception('Invalid material type = $type');
}
Expand Down Expand Up @@ -135,4 +140,21 @@ class Assets {
static ElementType getElementTypeFromPath(String path) {
return ElementType.values.firstWhere((type) => getElementPathFromType(type) == path);
}

static String getArtifactPathFromType(ArtifactType type) {
switch (type) {
case ArtifactType.clock:
return getMaterialPath('clock.png', MaterialType.others);
case ArtifactType.crown:
return getMaterialPath('crown.png', MaterialType.others);
case ArtifactType.flower:
return getMaterialPath('flower.png', MaterialType.others);
case ArtifactType.goblet:
return getMaterialPath('goblet.png', MaterialType.others);
case ArtifactType.plume:
return getMaterialPath('plume.png', MaterialType.others);
default:
throw Exception('Invalid artifact type = $type');
}
}
}
7 changes: 7 additions & 0 deletions lib/common/enums/artifact_type.dart
@@ -0,0 +1,7 @@
enum ArtifactType {
flower,
plume,
clock,
goblet,
crown,
}
1 change: 1 addition & 0 deletions lib/common/enums/material_type.dart
Expand Up @@ -7,4 +7,5 @@ enum MaterialType {
weapon,
weaponPrimary,
currency,
others,
}
6 changes: 3 additions & 3 deletions lib/ui/pages/elements_page.dart
Expand Up @@ -27,7 +27,7 @@ class ElementsPage extends StatelessWidget {
s.elementalDebuffs,
style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold),
),
Text(s.elementalDebuffsExplainded)
Text(s.elementalDebuffsExplained)
],
),
),
Expand All @@ -41,7 +41,7 @@ class ElementsPage extends StatelessWidget {
s.elementalReactions,
style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold),
),
Text(s.elementalReactionsExplainded),
Text(s.elementalReactionsExplained),
]),
),
),
Expand All @@ -54,7 +54,7 @@ class ElementsPage extends StatelessWidget {
s.elementalResonances,
style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold),
),
Text(s.elemetalResonancesExplanined),
Text(s.elementalResonancesExplained),
]),
),
),
Expand Down
102 changes: 39 additions & 63 deletions lib/ui/widgets/artifacts/artifact_bottom_sheet.dart
Expand Up @@ -5,83 +5,59 @@ import '../../../bloc/bloc.dart';
import '../../../common/enums/artifact_filter_type.dart';
import '../../../common/extensions/i18n_extensions.dart';
import '../../../common/genshin_db_icons.dart';
import '../../../common/styles.dart';
import '../../../generated/l10n.dart';
import '../common/bottom_sheet_title.dart';
import '../common/common_bottom_sheet.dart';
import '../common/item_popupmenu_filter.dart';
import '../common/loading.dart';
import '../common/modal_sheet_separator.dart';
import '../common/rarity_rating.dart';
import '../common/sort_direction_popupmenu_filter.dart';

class ArtifactBottomSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final s = S.of(context);
return SingleChildScrollView(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Container(
margin: Styles.modalBottomSheetContainerMargin,
padding: Styles.modalBottomSheetContainerPadding,
child: BlocBuilder<ArtifactsBloc, ArtifactsState>(
builder: (context, state) {
return state.map(
loading: (_) => const Loading(),
loaded: (state) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
ModalSheetSeparator(),
BottomSheetTitle(icon: GenshinDb.filter, title: s.filters),
Text(s.rarity),
RarityRating(
rarity: state.rarity,
onRated: (v) => context.read<ArtifactsBloc>().add(ArtifactsEvent.rarityChanged(v)),
),
Text(s.others),
ButtonBar(
alignment: MainAxisAlignment.spaceEvenly,
children: [
ItemPopupMenuFilter<ArtifactFilterType>(
tooltipText: s.sortBy,
onSelected: (v) =>
context.read<ArtifactsBloc>().add(ArtifactsEvent.artifactFilterTypeChanged(v)),
selectedValue: state.tempArtifactFilterType,
values: ArtifactFilterType.values,
itemText: (val) => s.translateArtifactFilterType(val),
),
SortDirectionPopupMenuFilter(
selectedSortDirection: state.tempSortDirectionType,
onSelected: (v) =>
context.read<ArtifactsBloc>().add(ArtifactsEvent.sortDirectionTypeChanged(v)),
)
],
return CommonBottomSheet(
titleIcon: GenshinDb.filter,
title: s.filters,
onOk: () {
context.read<ArtifactsBloc>().add(const ArtifactsEvent.applyFilterChanges());
Navigator.pop(context);
},
onCancel: () {
context.read<ArtifactsBloc>().add(const ArtifactsEvent.cancelChanges());
Navigator.pop(context);
},
child: BlocBuilder<ArtifactsBloc, ArtifactsState>(
builder: (context, state) => state.map(
loading: (_) => const Loading(),
loaded: (state) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text(s.rarity),
RarityRating(
rarity: state.rarity,
onRated: (v) => context.read<ArtifactsBloc>().add(ArtifactsEvent.rarityChanged(v)),
),
Text(s.others),
ButtonBar(
alignment: MainAxisAlignment.spaceEvenly,
children: [
ItemPopupMenuFilter<ArtifactFilterType>(
tooltipText: s.sortBy,
onSelected: (v) => context.read<ArtifactsBloc>().add(ArtifactsEvent.artifactFilterTypeChanged(v)),
selectedValue: state.tempArtifactFilterType,
values: ArtifactFilterType.values,
itemText: (val) => s.translateArtifactFilterType(val),
),
ButtonBar(
buttonPadding: const EdgeInsets.symmetric(horizontal: 10),
children: <Widget>[
OutlineButton(
onPressed: () {
context.read<ArtifactsBloc>().add(const ArtifactsEvent.cancelChanges());
Navigator.pop(context);
},
child: Text(s.cancel, style: TextStyle(color: theme.primaryColor)),
),
RaisedButton(
color: theme.primaryColor,
onPressed: () {
context.read<ArtifactsBloc>().add(const ArtifactsEvent.applyFilterChanges());
Navigator.pop(context);
},
child: Text(s.ok),
)
],
SortDirectionPopupMenuFilter(
selectedSortDirection: state.tempSortDirectionType,
onSelected: (v) => context.read<ArtifactsBloc>().add(ArtifactsEvent.sortDirectionTypeChanged(v)),
)
],
),
);
},
],
),
),
),
);
Expand Down
11 changes: 10 additions & 1 deletion lib/ui/widgets/artifacts/artifact_info_card.dart
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';

import '../../../common/assets.dart';
import '../../../common/enums/artifact_type.dart';
import '../../../common/enums/element_type.dart';
import '../../../common/enums/stat_type.dart';
import '../../../common/extensions/i18n_extensions.dart';
Expand Down Expand Up @@ -47,7 +49,14 @@ class ArtifactInfoCard extends StatelessWidget {

final panel = ItemExpansionPanel(
title: s.note,
body: BulletList(items: considerations),
body: BulletList(
items: considerations,
iconResolver: (index) => Image.asset(
Assets.getArtifactPathFromType(ArtifactType.values[index]),
width: 24,
height: 24,
),
),
icon: const Icon(Icons.info_outline),
isCollapsed: isCollapsed,
expansionCallback: expansionCallback,
Expand Down
Expand Up @@ -24,7 +24,7 @@ class CharacterAscentionMaterials extends StatelessWidget {
)
.toList();
return Tooltip(
message: s.ascentionMaterials,
message: s.ascensionMaterials,
child: Wrap(
alignment: WrapAlignment.spaceEvenly,
crossAxisAlignment: WrapCrossAlignment.center,
Expand Down

0 comments on commit 330ba74

Please sign in to comment.