Skip to content

Commit

Permalink
[Presentation] [WIP] Initial mock for the custom builds page
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jan 1, 2022
1 parent e05b5c4 commit 62e4c69
Show file tree
Hide file tree
Showing 21 changed files with 1,024 additions and 119 deletions.
12 changes: 12 additions & 0 deletions lib/injection.dart
Expand Up @@ -131,6 +131,18 @@ class Injection {
return WeaponBloc(genshinService, telemetryService, dataService);
}

static CustomBuildsBloc get customBuildsBloc {
final genshinService = getIt<GenshinService>();
final dataService = getIt<DataService>();
return CustomBuildsBloc(genshinService, dataService);
}

static CustomBuildBloc get customBuildBloc {
final genshinService = getIt<GenshinService>();
final dataService = getIt<DataService>();
return CustomBuildBloc(genshinService, dataService);
}

//TODO: USE THIS PROP
// static CalculatorAscMaterialsItemBloc get calculatorAscMaterialsItemBloc {
// final genshinService = getIt<GenshinService>();
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/artifacts/artifacts_page.dart
Expand Up @@ -18,9 +18,9 @@ import 'widgets/artifact_info_card.dart';
class ArtifactsPage extends StatefulWidget {
final bool isInSelectionMode;

static Future<String?> forSelection(BuildContext context, {List<String> excludeKeys = const []}) async {
static Future<String?> forSelection(BuildContext context, {List<String> excludeKeys = const [], ArtifactType? type}) async {
final bloc = context.read<ArtifactsBloc>();
bloc.add(ArtifactsEvent.init(excludeKeys: excludeKeys));
bloc.add(ArtifactsEvent.init(excludeKeys: excludeKeys, type: type));

final route = MaterialPageRoute<String>(builder: (ctx) => const ArtifactsPage(isInSelectionMode: true));
final keyName = await Navigator.of(context).push(route);
Expand Down
26 changes: 10 additions & 16 deletions lib/presentation/artifacts/widgets/artifact_info_card.dart
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:shiori/domain/assets.dart';
import 'package:shiori/domain/enums/enums.dart';
import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/shared/bullet_list.dart';
import 'package:shiori/presentation/shared/extensions/i18n_extensions.dart';
import 'package:shiori/presentation/shared/images/artifact_image_type.dart';
import 'package:shiori/presentation/shared/item_expansion_panel.dart';

class ArtifactInfoCard extends StatelessWidget {
Expand All @@ -19,7 +19,6 @@ class ArtifactInfoCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final s = S.of(context);
final theme = Theme.of(context);
final considerations = <String>[];

final hp = s.translateStatTypeWithoutValue(StatType.hp, removeExtraSigns: true);
Expand All @@ -43,22 +42,17 @@ class ArtifactInfoCard extends StatelessWidget {
considerations.add(
'${s.crown}: $atkPercentage / $defPercentage / $hpPercentage / $critRate / $critDmg / $elementaryMastery / ${s.healingBonus}',
);

final panel = ItemExpansionPanel(
title: s.note,
body: BulletList(
items: considerations,
iconResolver: (index) => Image.asset(
Assets.getArtifactPathFromType(ArtifactType.values[index]),
width: 24,
height: 24,
color: theme.brightness == Brightness.dark ? Colors.white : Colors.black,
return SliverToBoxAdapter(
child: ItemExpansionPanel(
title: s.note,
body: BulletList(
items: considerations,
iconResolver: (index) => ArtifactImageType(index: index),
),
icon: const Icon(Icons.info_outline),
isCollapsed: isCollapsed,
expansionCallback: expansionCallback,
),
icon: const Icon(Icons.info_outline),
isCollapsed: isCollapsed,
expansionCallback: expansionCallback,
);
return SliverToBoxAdapter(child: panel);
}
}
Expand Up @@ -7,6 +7,7 @@ import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/artifacts/widgets/artifact_card.dart';
import 'package:shiori/presentation/shared/extensions/element_type_extensions.dart';
import 'package:shiori/presentation/shared/extensions/i18n_extensions.dart';
import 'package:shiori/presentation/shared/row_column_item_or.dart';
import 'package:shiori/presentation/shared/styles.dart';
import 'package:shiori/presentation/weapons/widgets/weapon_card.dart';

Expand Down Expand Up @@ -91,7 +92,7 @@ class CharacterDetailBuildCard extends StatelessWidget {
...artifacts.mapIndex((e, index) {
final showOr = index < artifacts.length - 1;
if (showOr) {
return _ItemWithOr(widget: _ArtifactRow(item: e), color: color, useColumn: true);
return RowColumnItemOr(widget: _ArtifactRow(item: e), color: color, useColumn: true);
}
return _ArtifactRow(item: e);
}).toList(),
Expand Down Expand Up @@ -131,7 +132,7 @@ class _Weapons extends StatelessWidget {
);
final withOr = index < weapons.length - 1;
if (withOr) {
return _ItemWithOr(widget: child, color: color);
return RowColumnItemOr(widget: child, color: color);
}
return child;
},
Expand All @@ -140,33 +141,6 @@ class _Weapons extends StatelessWidget {
}
}

class _ItemWithOr extends StatelessWidget {
final Widget widget;
final Color color;
final bool useColumn;

const _ItemWithOr({
Key? key,
required this.widget,
required this.color,
this.useColumn = false,
}) : super(key: key);

@override
Widget build(BuildContext context) {
if (useColumn) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [widget, _OrWidget(color: color)],
);
}
return Row(
mainAxisSize: MainAxisSize.min,
children: [widget, _OrWidget(color: color)],
);
}
}

class _ArtifactRow extends StatelessWidget {
final CharacterBuildArtifactModel item;

Expand Down Expand Up @@ -223,36 +197,6 @@ class _ArtifactRow extends StatelessWidget {
}
}

class _OrWidget extends StatelessWidget {
final Color color;

const _OrWidget({
Key? key,
required this.color,
}) : super(key: key);

@override
Widget build(BuildContext context) {
final s = S.of(context);
final theme = Theme.of(context);
return Container(
margin: Styles.edgeInsetAll5,
padding: Styles.edgeInsetAll5,
decoration: BoxDecoration(
color: color,
shape: BoxShape.circle,
),
child: Center(
child: Text(
s.or,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle2!.copyWith(fontWeight: FontWeight.bold, color: Colors.white),
),
),
);
}
}

class _SubStatToFocus extends StatelessWidget {
final List<StatType> subStatsToFocus;
final Color color;
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/characters/characters_page.dart
Expand Up @@ -19,6 +19,7 @@ class CharactersPage extends StatefulWidget {

static Future<String?> forSelection(BuildContext context, {List<String> excludeKeys = const []}) async {
final bloc = context.read<CharactersBloc>();
//TODO: RECEIVE THE EXCLUDEKEYS IN THE CONSTRUCTOR AND REMOVE THIS BLOC FROM HERE
bloc.add(CharactersEvent.init(excludeKeys: excludeKeys));

final route = MaterialPageRoute<String>(builder: (ctx) => const CharactersPage(isInSelectionMode: true));
Expand Down

0 comments on commit 62e4c69

Please sign in to comment.