Skip to content

Commit

Permalink
Add texture option in visual editing tool
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 10, 2025
1 parent 2360051 commit cc76864
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 18 deletions.
8 changes: 4 additions & 4 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ packages:
dependency: transitive
description:
name: pubspec_parse
sha256: "81876843eb50dc2e1e5b151792c9a985c5ed2536914115ed04e9c8528f6647b0"
sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082"
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.5.0"
shelf:
dependency: transitive
description:
Expand Down Expand Up @@ -445,10 +445,10 @@ packages:
dependency: transitive
description:
name: stream_channel
sha256: "4ac0537115a24d772c408a2520ecd0abb99bca2ea9c4e634ccbdbfae64fe17ec"
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
version: "2.1.4"
stream_transform:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.1033.0)
aws-partitions (1.1034.0)
aws-sdk-core (3.214.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
Expand Down
4 changes: 2 additions & 2 deletions app/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionSha256Sum=7a00d51fb93147819aab76024feece20b6b84e420694101f276be952e08bef03
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.7.2' apply false
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
id "com.android.application" version '8.7.3' apply false
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
}

include ":app"
4 changes: 3 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,7 @@
"offset": "Offset",
"wholeSizeClickCustomize": "Whole size, click to customize",
"clear": "Clear",
"textures": "Textures"
"textures": "Textures",
"texture": "Texture",
"notSet": "Not set"
}
1 change: 1 addition & 0 deletions app/lib/pages/editor/shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class EditorNavigatorView extends StatelessWidget {
return NavigationDrawer(
selectedIndex: isMobile ? currentPage.index + 1 : currentPage.index,
onDestinationSelected: (value) {
if (isMobile) Navigator.of(context).pop();
if (isMobile && value == 0) {
context.go('/');
} else {
Expand Down
59 changes: 59 additions & 0 deletions app/lib/pages/editor/textures.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,51 @@ class TexturesEditorPage extends StatelessWidget {
}
}

class EditorTextureListTile extends StatelessWidget {
final String? label;
final String value;
final ValueChanged<String> onChanged;
final VoidCallback? onRemove;

const EditorTextureListTile({
super.key,
this.label,
required this.value,
required this.onChanged,
this.onRemove,
});

@override
Widget build(BuildContext context) {
return BlocBuilder<EditorCubit, SetonixData>(
builder: (context, state) {
final data = state.getTexture(value);
return ListTile(
title: Text(label ?? AppLocalizations.of(context).texture),
subtitle:
Text(value.isEmpty ? AppLocalizations.of(context).notSet : ''),
leading:
data == null ? null : Image.memory(data, width: 48, height: 48),
onTap: () => showDialog(
context: context,
builder: (context) =>
TextureDialog(textures: state.getTexturesData()),
).then((texture) {
if (texture == null) return;
onChanged(texture);
}),
trailing: onRemove == null
? null
: IconButton(
icon: const Icon(PhosphorIconsLight.trash),
onPressed: onRemove,
),
);
},
);
}
}

class TextureDialog extends StatelessWidget {
final Map<String, Uint8List?> textures;

Expand All @@ -80,6 +125,12 @@ class TextureDialog extends StatelessWidget {
content: _TexturesColumn(
textures: textures,
onClick: (texture) => Navigator.of(context).pop(texture)),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(AppLocalizations.of(context).cancel),
),
],
);
}
}
Expand Down Expand Up @@ -139,6 +190,14 @@ class VisualEditingView<T extends VisualDefinition> extends StatelessWidget {
final size = value.size;
return Column(
children: [
EditorTextureListTile(
value: value.texture,
onChanged: (texture) =>
onChanged(value.copyWith(texture: texture) as T),
onRemove: value.texture.isEmpty
? null
: () => onChanged(value.copyWith(texture: '') as T),
),
OffsetListTile(
value: value.offset.toOffset(),
title: Text(AppLocalizations.of(context).offset),
Expand Down
16 changes: 8 additions & 8 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,10 @@ packages:
dependency: "direct main"
description:
name: flutter_secure_storage
sha256: c0f1abb088adddc193286ea91eedd71900ec5707ac86503a7ae09d88c9ffc22b
sha256: "127f5ab0b6402baa7a3322bddb419a22874f7b5b1e12c9946e329c7f846d8e4e"
url: "https://pub.dev"
source: hosted
version: "10.0.0-beta.2"
version: "10.0.0-beta.3"
flutter_secure_storage_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -506,10 +506,10 @@ packages:
dependency: "direct main"
description:
name: flutter_svg
sha256: "54900a1a1243f3c4a5506d853a2b5c2dbc38d5f27e52a52618a8054401431123"
sha256: c200fd79c918a40c5cd50ea0877fa13f81bdaf6f0a5d3dbcc2a13e3285d6aa1b
url: "https://pub.dev"
source: hosted
version: "2.0.16"
version: "2.0.17"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -614,10 +614,10 @@ packages:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
url: "https://pub.dev"
source: hosted
version: "0.6.7"
version: "0.7.1"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -1289,10 +1289,10 @@ packages:
dependency: transitive
description:
name: url_launcher_web
sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e"
sha256: "3ba963161bd0fe395917ba881d320b9c4f6dd3c4a233da62ab18a5025c85f1e9"
url: "https://pub.dev"
source: hosted
version: "2.3.3"
version: "2.4.0"
url_launcher_windows:
dependency: transitive
description:
Expand Down

0 comments on commit cc76864

Please sign in to comment.