@@ -64,6 +64,51 @@ class TexturesEditorPage extends StatelessWidget {
64
64
}
65
65
}
66
66
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
+
67
112
class TextureDialog extends StatelessWidget {
68
113
final Map <String , Uint8List ?> textures;
69
114
@@ -80,6 +125,12 @@ class TextureDialog extends StatelessWidget {
80
125
content: _TexturesColumn (
81
126
textures: textures,
82
127
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
+ ],
83
134
);
84
135
}
85
136
}
@@ -139,6 +190,14 @@ class VisualEditingView<T extends VisualDefinition> extends StatelessWidget {
139
190
final size = value.size;
140
191
return Column (
141
192
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
+ ),
142
201
OffsetListTile (
143
202
value: value.offset.toOffset (),
144
203
title: Text (AppLocalizations .of (context).offset),
0 commit comments