Skip to content

Commit

Permalink
[Presentation] Crash fix on the inventory_page.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jan 9, 2022
1 parent 294610b commit 7ab9e0e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion assets/i18n/ru.json
Expand Up @@ -10235,7 +10235,7 @@
{
"key": "vaporize-reverse",
"name": "Пар (на оборот)",
"effect": "Добавляет х1.5 к урону, если нанести Пиро урон по Крио.",
"effect": "Добавляет х1.5 к урону, если нанести Пиро урон по Гидро.",
"description": null
},
{
Expand Down
58 changes: 35 additions & 23 deletions lib/presentation/inventory/inventory_page.dart
Expand Up @@ -8,32 +8,17 @@ import 'package:shiori/presentation/inventory/widgets/clear_all_dialog.dart';
import 'package:shiori/presentation/inventory/widgets/materials_inventory_tab_page.dart';
import 'package:shiori/presentation/inventory/widgets/weapons_inventory_tab_page.dart';
import 'package:shiori/presentation/shared/shiori_icons.dart';
import 'package:shiori/presentation/shared/styles.dart';

class InventoryPage extends StatelessWidget {
final tabs = const [
Tab(icon: Icon(Icons.people)),
Tab(icon: Icon(Shiori.crossed_swords)),
Tab(icon: Icon(Shiori.cubes)),
];

@override
Widget build(BuildContext context) {
final s = S.of(context);
return BlocProvider(
create: (context) => Injection.inventoryBloc..add(const InventoryEvent.init()),
child: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
title: Text(s.myInventory),
bottom: TabBar(tabs: tabs, indicatorColor: Theme.of(context).colorScheme.secondary),
actions: [
IconButton(
icon: const Icon(Icons.clear_all),
onPressed: () => _showClearInventoryDialog(context),
)
],
),
appBar: const _AppBar(),
body: SafeArea(
child: TabBarView(
children: [
Expand All @@ -47,14 +32,41 @@ class InventoryPage extends StatelessWidget {
),
);
}
}

class _AppBar extends StatelessWidget implements PreferredSizeWidget {
const _AppBar({Key? key}) : super(key: key);

Future<void> _showClearInventoryDialog(BuildContext context) async {
await showDialog(
context: context,
builder: (_) => BlocProvider.value(
value: context.read<InventoryBloc>(),
child: const ClearAllDialog(),
@override
Widget build(BuildContext context) {
final s = S.of(context);
return AppBar(
title: Text(s.myInventory),
bottom: TabBar(
tabs: const [
Tab(icon: Icon(Icons.people)),
Tab(icon: Icon(Shiori.crossed_swords)),
Tab(icon: Icon(Shiori.cubes)),
],
indicatorColor: Theme.of(context).colorScheme.secondary,
),
actions: [
IconButton(
icon: const Icon(Icons.clear_all),
splashRadius: Styles.mediumButtonSplashRadius,
onPressed: () => showDialog(
context: context,
builder: (_) => BlocProvider.value(
value: context.read<InventoryBloc>(),
child: const ClearAllDialog(),
),
),
)
],
);
}

@override
//toolbar + tabbar + indicator height
Size get preferredSize => const Size.fromHeight(kToolbarHeight + 46 + 2);
}

0 comments on commit 7ab9e0e

Please sign in to comment.