Skip to content

Commit ece8949

Browse files
committed
Merge branch 'develop'
2 parents 38978be + 684d92d commit ece8949

18 files changed

+312
-154
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
# DST Helper
22

3-
It is an application that can give a help when you play the _Don't Starve Together_.
3+
An application that provides useful features and information when you play the _Don't Starve Together_ 🎮
44

5-
## Shortcut links
5+
## Links
66

77
### Web
88
- Product: https://woin2ee.github.io/DST-Helper-web/
99
- Github: https://github.com/woin2ee/DST-Helper-web
1010

11+
### MacOS
12+
Upcoming deployment...
13+
14+
### iOS & Android
15+
It's not planned yet.
16+
1117
## ❗️Important
1218

13-
This application is not official app for **Klei Entertainment**.
19+
This application is not an official app of **Klei Entertainment**.
1420

1521
It is a `Player Creation` according to the [Player Creation Guidelines](https://support.klei.com/hc/en-us/articles/360029880791-Player-Creation-Guidelines).
1622

17-
If you want to see the more games of **Klei**, check out [Here!](https://www.klei.com/)
23+
If you want to see more games of **Klei**, check out [Here!](https://www.klei.com/)

lib/app/home_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class HomePage extends StatefulWidget {
2727
}
2828

2929
class _HomePageState extends State<HomePage> {
30-
// Only debug use
30+
// Only use in developing
3131
static const _firstPageIndex = kReleaseMode ? 0 : 0;
3232

3333
final List<(Menu, bool)> _selectedMenuState = Menu.values.map((menu) {

lib/cook_page/cook_page.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:dst_helper/cook_page/recipe_card_table.dart';
22
import 'package:dst_helper/cook_page/recipe_list/recipe_list.dart';
3+
import 'package:dst_helper/models/v2/item/item.dart';
34
import 'package:flutter/material.dart';
45

56
class CookPage extends StatefulWidget {
@@ -10,6 +11,12 @@ class CookPage extends StatefulWidget {
1011
}
1112

1213
class _CookPageState extends State<CookPage> {
14+
@override
15+
void didChangeDependencies() {
16+
super.didChangeDependencies();
17+
_prefetchImagesToNeed(context);
18+
}
19+
1320
@override
1421
Widget build(BuildContext context) {
1522
return Container(
@@ -25,4 +32,31 @@ class _CookPageState extends State<CookPage> {
2532
),
2633
);
2734
}
35+
36+
void _prefetchImagesToNeed(BuildContext context) {
37+
precacheImage(const AssetImage('assets/images/frame_1.png'), context);
38+
precacheImage(const AssetImage('assets/images/frame_2_thick.png'), context);
39+
40+
for (final ingredient in Items.ingredients) {
41+
_prefetchIngredientImage(ingredient, context);
42+
}
43+
44+
for (final category in FoodValueCategory.values) {
45+
precacheImage(AssetImage('assets/images/items/${category.assetName}.png'), context);
46+
}
47+
}
48+
49+
void _prefetchIngredientImage(Item ingredient, BuildContext context) {
50+
if (ingredient is CookableFood) {
51+
precacheImage(
52+
AssetImage('assets/images/items/${ingredient.compositeAssetName}.png'),
53+
context,
54+
);
55+
return;
56+
}
57+
precacheImage(
58+
AssetImage('assets/images/items/${ingredient.assetName}.png'),
59+
context,
60+
);
61+
}
2862
}

lib/cook_page/recipe_card/default_recipe_card.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_card.dart';
1+
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_image.dart';
22
import 'package:dst_helper/cook_page/recipe_card/status_pair.dart';
33
import 'package:dst_helper/l10n/l10ns.dart';
44
import 'package:dst_helper/models/v2/item/categories.dart';
@@ -25,7 +25,7 @@ class DefaultRecipeCard extends StatelessWidget {
2525
return Draggable<Recipe>(
2626
data: recipe,
2727
dragAnchorStrategy: pointerDragAnchorStrategy,
28-
feedback: DraggingRecipeCard(imageAssetName: recipe.assetName),
28+
feedback: DraggingRecipeImage(assetName: recipe.assetName),
2929
child: _DropShadowedContainer(
3030
width: width,
3131
padding: const EdgeInsets.only(top: vPadding, left: hPadding, right: hPadding, bottom: vPadding),

lib/cook_page/recipe_card/detail_recipe_card.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_card.dart';
1+
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_image.dart';
22
import 'package:dst_helper/cook_page/recipe_card/status_pair.dart';
33
import 'package:dst_helper/l10n/l10ns.dart';
44
import 'package:dst_helper/models/v2/item/categories.dart';
@@ -25,7 +25,7 @@ class DetailRecipeCard extends StatelessWidget {
2525
return Draggable<Recipe>(
2626
data: recipe,
2727
dragAnchorStrategy: pointerDragAnchorStrategy,
28-
feedback: DraggingRecipeCard(imageAssetName: recipe.assetName),
28+
feedback: DraggingRecipeImage(assetName: recipe.assetName),
2929
child: _DropShadowedContainer(
3030
width: width,
3131
padding: const EdgeInsets.all(padding),

lib/cook_page/recipe_card/dragging_recipe_card.dart renamed to lib/cook_page/recipe_card/dragging_recipe_image.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import 'package:flutter/material.dart';
22

3-
class DraggingRecipeCard extends StatelessWidget {
4-
const DraggingRecipeCard({
3+
class DraggingRecipeImage extends StatelessWidget {
4+
const DraggingRecipeImage({
55
super.key,
6-
required this.imageAssetName,
6+
required this.assetName,
77
});
88

9-
final String imageAssetName;
9+
final String assetName;
1010

1111
@override
1212
Widget build(BuildContext context) {
@@ -15,9 +15,8 @@ class DraggingRecipeCard extends StatelessWidget {
1515
child: Opacity(
1616
opacity: 0.85,
1717
child: Image(
18-
image: AssetImage(
19-
'assets/images/items/$imageAssetName.png',
20-
)),
18+
image: AssetImage('assets/images/items/$assetName.png'),
19+
),
2120
),
2221
);
2322
}

lib/cook_page/recipe_card/only_image_recipe_card.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_card.dart';
1+
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_image.dart';
22
import 'package:dst_helper/models/v2/item/categories.dart';
33
import 'package:flutter/material.dart';
44

@@ -18,7 +18,7 @@ class OnlyImageRecipeCard extends StatelessWidget {
1818
return Draggable<Recipe>(
1919
data: recipe,
2020
dragAnchorStrategy: pointerDragAnchorStrategy,
21-
feedback: DraggingRecipeCard(imageAssetName: recipe.assetName),
21+
feedback: DraggingRecipeImage(assetName: recipe.assetName),
2222
child: _DropShadowedContainer(
2323
padding: const EdgeInsets.all(padding),
2424
borderRadius: const BorderRadius.all(Radius.circular(15)),

lib/cook_page/recipe_card/simple_recipe_card.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_card.dart';
1+
import 'package:dst_helper/cook_page/recipe_card/dragging_recipe_image.dart';
22
import 'package:dst_helper/l10n/l10ns.dart';
33
import 'package:dst_helper/models/v2/item/categories.dart';
44
import 'package:dst_helper/utils/etc.dart';
@@ -23,7 +23,7 @@ class SimpleRecipeCard extends StatelessWidget {
2323
return Draggable<Recipe>(
2424
data: recipe,
2525
dragAnchorStrategy: pointerDragAnchorStrategy,
26-
feedback: DraggingRecipeCard(imageAssetName: recipe.assetName),
26+
feedback: DraggingRecipeImage(assetName: recipe.assetName),
2727
child: _DropShadowedContainer(
2828
width: width,
2929
padding: const EdgeInsets.all(padding),

lib/cook_page/recipe_list/recipe_list.dart

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import 'package:dst_helper/l10n/l10ns.dart';
44
import 'package:dst_helper/models/v2/item/item.dart';
55
import 'package:dst_helper/utils/font_family.dart';
66
import 'package:flutter/material.dart';
7-
import 'package:intl/intl.dart';
87
import 'package:toastification/toastification.dart';
98

109
class RecipeList extends StatefulWidget {
1110
RecipeList() : super(key: GlobalKey());
1211

13-
GlobalKey get globalKey => key as GlobalKey;
12+
static const double width = 410;
1413

1514
@override
1615
State<RecipeList> createState() => _RecipeListState();
@@ -32,7 +31,7 @@ class _RecipeListState extends State<RecipeList> {
3231
},
3332
builder: (context, candidateItems, rejectedItems) {
3433
return Container(
35-
width: 410,
34+
width: RecipeList.width,
3635
decoration: const BoxDecoration(
3736
color: Colors.white,
3837
border: Border(
@@ -42,54 +41,51 @@ class _RecipeListState extends State<RecipeList> {
4241
),
4342
),
4443
),
45-
child: ListenableBuilder(
46-
listenable: _recipeListNotifier,
47-
builder: (context, child) {
48-
final recipeList = _recipeListNotifier.value;
49-
if (recipeList.isEmpty) {
50-
return Center(
51-
child: Text(
52-
L10ns.of(context).localized('recipe_list_guide_message'),
53-
style: const TextStyle(
54-
fontFamily: FontFamily.pretendard,
55-
fontSize: 14,
56-
),
57-
),
58-
);
59-
}
60-
return ListView.separated(
61-
padding: const EdgeInsets.only(top: 24, left: 32, right: 32, bottom: 24),
62-
itemCount: recipeList.length,
63-
itemBuilder: (context, index) => FittedBox(
64-
child: DraggableRecipeListItem(
65-
recipe: recipeList[index],
66-
recipeListKey: widget.globalKey,
44+
child: recipeListContent(),
45+
);
46+
},
47+
);
48+
}
49+
50+
Widget recipeListContent() {
51+
return ListenableBuilder(
52+
listenable: _recipeListNotifier,
53+
builder: (context, child) {
54+
final recipeList = _recipeListNotifier.value;
55+
if (recipeList.isEmpty) {
56+
return const _EmptyListText();
57+
}
58+
return ReorderableListView(
59+
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
60+
children: [
61+
..._recipeListNotifier.value.asMap().entries.map((recipe) => DraggableRecipeListItem(
62+
key: Key('${recipe.key}'),
63+
recipe: recipe.value,
64+
recipeListWidgetKey: widget.key as GlobalKey,
6765
recipeListNotifier: _recipeListNotifier,
6866
)),
69-
separatorBuilder: (context, index) => const Divider(color: Color(0xffBEBEBE)),
70-
);
71-
},
72-
),
67+
],
68+
onReorder: (oldIndex, newIndex) => setState(() {
69+
if (oldIndex < newIndex) {
70+
newIndex -= 1;
71+
}
72+
final item = _recipeListNotifier.removeAt(oldIndex);
73+
_recipeListNotifier.insert(newIndex, item);
74+
}),
7375
);
7476
},
7577
);
7678
}
7779

7880
void _showToast(BuildContext context) {
79-
String message() => Intl.message(
80-
'The recipe is already registered.',
81-
desc: "It's showed up when a duplicated recipe card is registered to list.",
82-
locale: Localizations.localeOf(context).languageCode,
83-
);
84-
8581
toastification.show(
8682
context: context,
8783
alignment: Alignment.bottomCenter,
8884
icon: const Icon(Icons.warning),
8985
style: ToastificationStyle.flatColored,
9086
primaryColor: Colors.grey,
9187
backgroundColor: Colors.grey.shade100,
92-
title: Text(message()),
88+
title: Text(L10ns.of(context).recipeList.toastMessage()),
9389
autoCloseDuration: const Duration(seconds: 2),
9490
animationDuration: const Duration(milliseconds: 300),
9591
pauseOnHover: false,
@@ -98,3 +94,20 @@ class _RecipeListState extends State<RecipeList> {
9894
);
9995
}
10096
}
97+
98+
class _EmptyListText extends StatelessWidget {
99+
const _EmptyListText();
100+
101+
@override
102+
Widget build(BuildContext context) {
103+
return Center(
104+
child: Text(
105+
L10ns.of(context).localized('recipe_list_guide_message'),
106+
style: const TextStyle(
107+
fontFamily: FontFamily.pretendard,
108+
fontSize: 14,
109+
),
110+
),
111+
);
112+
}
113+
}

0 commit comments

Comments
 (0)