Skip to content

Commit cc76864

Browse files
committed
Add texture option in visual editing tool
1 parent 2360051 commit cc76864

File tree

8 files changed

+80
-18
lines changed

8 files changed

+80
-18
lines changed

api/pubspec.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ packages:
397397
dependency: transitive
398398
description:
399399
name: pubspec_parse
400-
sha256: "81876843eb50dc2e1e5b151792c9a985c5ed2536914115ed04e9c8528f6647b0"
400+
sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082"
401401
url: "https://pub.dev"
402402
source: hosted
403-
version: "1.4.0"
403+
version: "1.5.0"
404404
shelf:
405405
dependency: transitive
406406
description:
@@ -445,10 +445,10 @@ packages:
445445
dependency: transitive
446446
description:
447447
name: stream_channel
448-
sha256: "4ac0537115a24d772c408a2520ecd0abb99bca2ea9c4e634ccbdbfae64fe17ec"
448+
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
449449
url: "https://pub.dev"
450450
source: hosted
451-
version: "2.1.3"
451+
version: "2.1.4"
452452
stream_transform:
453453
dependency: transitive
454454
description:

app/android/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GEM
1010
artifactory (3.0.17)
1111
atomos (0.1.3)
1212
aws-eventstream (1.3.0)
13-
aws-partitions (1.1033.0)
13+
aws-partitions (1.1034.0)
1414
aws-sdk-core (3.214.1)
1515
aws-eventstream (~> 1, >= 1.3.0)
1616
aws-partitions (~> 1, >= 1.992.0)

app/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
3+
distributionSha256Sum=7a00d51fb93147819aab76024feece20b6b84e420694101f276be952e08bef03
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

app/android/settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version '8.7.2' apply false
22-
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
21+
id "com.android.application" version '8.7.3' apply false
22+
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
2323
}
2424

2525
include ":app"

app/lib/l10n/app_en.arb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,7 @@
219219
"offset": "Offset",
220220
"wholeSizeClickCustomize": "Whole size, click to customize",
221221
"clear": "Clear",
222-
"textures": "Textures"
222+
"textures": "Textures",
223+
"texture": "Texture",
224+
"notSet": "Not set"
223225
}

app/lib/pages/editor/shell.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class EditorNavigatorView extends StatelessWidget {
8484
return NavigationDrawer(
8585
selectedIndex: isMobile ? currentPage.index + 1 : currentPage.index,
8686
onDestinationSelected: (value) {
87+
if (isMobile) Navigator.of(context).pop();
8788
if (isMobile && value == 0) {
8889
context.go('/');
8990
} else {

app/lib/pages/editor/textures.dart

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,51 @@ class TexturesEditorPage extends StatelessWidget {
6464
}
6565
}
6666

67+
class EditorTextureListTile extends StatelessWidget {
68+
final String? label;
69+
final String value;
70+
final ValueChanged<String> onChanged;
71+
final VoidCallback? onRemove;
72+
73+
const EditorTextureListTile({
74+
super.key,
75+
this.label,
76+
required this.value,
77+
required this.onChanged,
78+
this.onRemove,
79+
});
80+
81+
@override
82+
Widget build(BuildContext context) {
83+
return BlocBuilder<EditorCubit, SetonixData>(
84+
builder: (context, state) {
85+
final data = state.getTexture(value);
86+
return ListTile(
87+
title: Text(label ?? AppLocalizations.of(context).texture),
88+
subtitle:
89+
Text(value.isEmpty ? AppLocalizations.of(context).notSet : ''),
90+
leading:
91+
data == null ? null : Image.memory(data, width: 48, height: 48),
92+
onTap: () => showDialog(
93+
context: context,
94+
builder: (context) =>
95+
TextureDialog(textures: state.getTexturesData()),
96+
).then((texture) {
97+
if (texture == null) return;
98+
onChanged(texture);
99+
}),
100+
trailing: onRemove == null
101+
? null
102+
: IconButton(
103+
icon: const Icon(PhosphorIconsLight.trash),
104+
onPressed: onRemove,
105+
),
106+
);
107+
},
108+
);
109+
}
110+
}
111+
67112
class TextureDialog extends StatelessWidget {
68113
final Map<String, Uint8List?> textures;
69114

@@ -80,6 +125,12 @@ class TextureDialog extends StatelessWidget {
80125
content: _TexturesColumn(
81126
textures: textures,
82127
onClick: (texture) => Navigator.of(context).pop(texture)),
128+
actions: [
129+
TextButton(
130+
onPressed: () => Navigator.of(context).pop(),
131+
child: Text(AppLocalizations.of(context).cancel),
132+
),
133+
],
83134
);
84135
}
85136
}
@@ -139,6 +190,14 @@ class VisualEditingView<T extends VisualDefinition> extends StatelessWidget {
139190
final size = value.size;
140191
return Column(
141192
children: [
193+
EditorTextureListTile(
194+
value: value.texture,
195+
onChanged: (texture) =>
196+
onChanged(value.copyWith(texture: texture) as T),
197+
onRemove: value.texture.isEmpty
198+
? null
199+
: () => onChanged(value.copyWith(texture: '') as T),
200+
),
142201
OffsetListTile(
143202
value: value.offset.toOffset(),
144203
title: Text(AppLocalizations.of(context).offset),

app/pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,10 @@ packages:
458458
dependency: "direct main"
459459
description:
460460
name: flutter_secure_storage
461-
sha256: c0f1abb088adddc193286ea91eedd71900ec5707ac86503a7ae09d88c9ffc22b
461+
sha256: "127f5ab0b6402baa7a3322bddb419a22874f7b5b1e12c9946e329c7f846d8e4e"
462462
url: "https://pub.dev"
463463
source: hosted
464-
version: "10.0.0-beta.2"
464+
version: "10.0.0-beta.3"
465465
flutter_secure_storage_linux:
466466
dependency: transitive
467467
description:
@@ -506,10 +506,10 @@ packages:
506506
dependency: "direct main"
507507
description:
508508
name: flutter_svg
509-
sha256: "54900a1a1243f3c4a5506d853a2b5c2dbc38d5f27e52a52618a8054401431123"
509+
sha256: c200fd79c918a40c5cd50ea0877fa13f81bdaf6f0a5d3dbcc2a13e3285d6aa1b
510510
url: "https://pub.dev"
511511
source: hosted
512-
version: "2.0.16"
512+
version: "2.0.17"
513513
flutter_test:
514514
dependency: "direct dev"
515515
description: flutter
@@ -614,10 +614,10 @@ packages:
614614
dependency: transitive
615615
description:
616616
name: js
617-
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
617+
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
618618
url: "https://pub.dev"
619619
source: hosted
620-
version: "0.6.7"
620+
version: "0.7.1"
621621
json_annotation:
622622
dependency: transitive
623623
description:
@@ -1289,10 +1289,10 @@ packages:
12891289
dependency: transitive
12901290
description:
12911291
name: url_launcher_web
1292-
sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e"
1292+
sha256: "3ba963161bd0fe395917ba881d320b9c4f6dd3c4a233da62ab18a5025c85f1e9"
12931293
url: "https://pub.dev"
12941294
source: hosted
1295-
version: "2.3.3"
1295+
version: "2.4.0"
12961296
url_launcher_windows:
12971297
dependency: transitive
12981298
description:

0 commit comments

Comments
 (0)