Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 6cefc54

Browse files
Merge pull request #3 from Roman-Dzerkal/UI
UI
2 parents 32b5cfd + 0d228dd commit 6cefc54

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

lib/logic/mover_view.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,20 @@ class MoverView extends StatelessWidget {
8181
),
8282
),
8383
ElevatedButton(
84-
onPressed: model.openLogFile, child: const Text('Open')),
84+
onPressed: model.openLogFile,
85+
child: const Text('Open')),
8586
],
8687
),
8788
],
8889
),
8990
ElevatedButton(
90-
onPressed: model.startCopy, child: const Text('Start move')),
91+
onPressed: model.startButtonActive ? () => model.startCopy(context) : null,
92+
child: const Text('Start copy')),
93+
Text(model.message),
94+
Text('Current: ${model.currentTexture}'),
95+
LinearProgressIndicator(
96+
value: model.value,
97+
)
9198
]),
9299
),
93100
);

lib/logic/mover_vm.dart

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MoverViewModel extends BaseViewModel {
1515
String? targetFolderPath;
1616
String? logFilePath;
1717

18-
bool startButtonActive = true;
18+
bool startButtonActive = false;
1919

2020
final List<String> _extensions = [
2121
'.dds',
@@ -37,6 +37,10 @@ class MoverViewModel extends BaseViewModel {
3737

3838
String currentTexture = '';
3939
int amountTextures = 0;
40+
double value = 0.0;
41+
int i = 0;
42+
43+
String message = '';
4044

4145
void onReady() async {
4246
Directory appDocument = await getApplicationDocumentsDirectory();
@@ -90,9 +94,7 @@ class MoverViewModel extends BaseViewModel {
9094

9195
List<String> list = _getTexturesFromLog(platformLogFile.path!);
9296
BotToast.showText(text: 'Extracted ${list.length} textures');
93-
list.forEach((element) {
94-
print(element);
95-
});
97+
amountTextures = list.length;
9698
logFilePath = platformLogFile.path!;
9799
logFilePathController.text = platformLogFile.path!;
98100
if (_textures.isNotEmpty) {
@@ -101,9 +103,12 @@ class MoverViewModel extends BaseViewModel {
101103
_textures.addAll(list);
102104
list.clear();
103105
}
106+
startButtonActive = true;
107+
notifyListeners();
104108
}
105109

106-
void startCopy() {
110+
void startCopy(BuildContext context) async {
111+
message = 'Copying $amountTextures textures...';
107112
_checkExistence(_textures, sourceFolderPath!);
108113
}
109114

@@ -126,6 +131,13 @@ class MoverViewModel extends BaseViewModel {
126131

127132
void _checkExistence(List<String> textures, String sourceFolder) async {
128133
for (String texture in textures) {
134+
value = (i / textures.length);
135+
i = i + 1;
136+
currentTexture = texture;
137+
notifyListeners();
138+
/* Future.delayed(Duration(milliseconds: 1000))
139+
.then((value) => notifyListeners()); */
140+
129141
File textureFile = File(_context.join(sourceFolder, texture) + '.dds');
130142
bool exist = await textureFile.exists();
131143
if (exist) {
@@ -134,6 +146,11 @@ class MoverViewModel extends BaseViewModel {
134146
_notFound.writeAsStringSync(texture + '\n', mode: FileMode.append);
135147
}
136148
}
149+
BotToast.showText(
150+
text: 'All textures was copied success!',
151+
duration: Duration(seconds: 5));
152+
message = 'Copied!';
153+
notifyListeners();
137154
}
138155

139156
/// This method finds and copies the other files with required extensions

0 commit comments

Comments
 (0)