Skip to content

Commit cf469ef

Browse files
get ccx version number
1 parent db0fa0d commit cf469ef

File tree

6 files changed

+39
-3
lines changed

6 files changed

+39
-3
lines changed

lib/bloc/process_bloc/process_bloc.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ProcessBloc extends Bloc<ProcessEvent, ProcessState> {
2323
started: false,
2424
progress: '0',
2525
current: null,
26+
version: '0',
2627
));
2728

2829
Stream<ProcessState> _extractNext() async* {
@@ -159,6 +160,13 @@ class ProcessBloc extends Bloc<ProcessEvent, ProcessState> {
159160
.toList(),
160161
queue: state.queue.where((element) => element != event.file).toList(),
161162
);
163+
} else if (event is GetCCExtractorVersion) {
164+
String ccxVersion = await _extractor.getCCExtractorVersion;
165+
print(ccxVersion);
166+
yield state.copyWith(
167+
current: state.current,
168+
version: ccxVersion,
169+
);
162170
}
163171
}
164172
}

lib/bloc/process_bloc/process_event.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ class ProcessFileComplete extends ProcessEvent {
5454

5555
const ProcessFileComplete(this.file);
5656
}
57+
58+
class GetCCExtractorVersion extends ProcessEvent {}

lib/bloc/process_bloc/process_state.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ProcessState extends Equatable {
99
final List<String> videoDetails;
1010
final XFile? current;
1111
final bool started;
12-
12+
final String? version;
1313
const ProcessState({
1414
required this.orignalList,
1515
required this.queue,
@@ -19,6 +19,7 @@ class ProcessState extends Equatable {
1919
required this.started,
2020
required this.progress,
2121
required this.current,
22+
required this.version,
2223
});
2324

2425
ProcessState copyWith({
@@ -29,6 +30,7 @@ class ProcessState extends Equatable {
2930
List<String>? videoDetails,
3031
bool? started,
3132
String? progress,
33+
String? version,
3234
required XFile? current,
3335
}) =>
3436
ProcessState(
@@ -39,6 +41,7 @@ class ProcessState extends Equatable {
3941
started: started ?? this.started,
4042
progress: progress ?? this.progress,
4143
videoDetails: videoDetails ?? this.videoDetails,
44+
version: version ?? this.version,
4245
current: current,
4346
);
4447

@@ -51,6 +54,7 @@ class ProcessState extends Equatable {
5154
started,
5255
progress,
5356
videoDetails,
54-
orignalList
57+
orignalList,
58+
version,
5559
];
5660
}

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class MyApp extends StatelessWidget {
4545
create: (context) => DashboardBloc(),
4646
),
4747
BlocProvider<ProcessBloc>(
48-
create: (context) => ProcessBloc(),
48+
create: (context) => ProcessBloc()..add(GetCCExtractorVersion()),
4949
),
5050
BlocProvider<SettingsBloc>(
5151
create: (context) =>

lib/repositories/ccextractor.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,12 @@ class CCExtractor {
7272
void cancelRun() {
7373
process.kill();
7474
}
75+
76+
Future<String> get getCCExtractorVersion async {
77+
String ccxStdOut = '0';
78+
await Process.run('./ccextractorwinfull.exe', ['--version']).then((value) {
79+
ccxStdOut = value.stdout.toString().substring(224, 240);
80+
});
81+
return ccxStdOut;
82+
}
7583
}

lib/screens/home.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Flutter imports:
2+
import 'package:ccxgui/bloc/process_bloc/process_bloc.dart';
23
import 'package:ccxgui/screens/settings/input_settings.dart';
34
import 'package:ccxgui/screens/settings/obscure_settings.dart';
45
import 'package:ccxgui/screens/settings/output_settings.dart';
56
import 'package:flutter/material.dart';
7+
import 'package:flutter_bloc/flutter_bloc.dart';
68

79
// Package imports:
810
import 'package:flutter_svg/flutter_svg.dart';
@@ -35,6 +37,18 @@ class _HomeState extends State<Home> {
3537
semanticsLabel: 'CCExtractor Logo',
3638
),
3739
),
40+
BlocBuilder<ProcessBloc, ProcessState>(
41+
builder: (context, state) {
42+
return Text(
43+
state.version!.trim(),
44+
style: TextStyle(
45+
fontSize: 12,
46+
color: Theme.of(context)
47+
.bottomNavigationBarTheme
48+
.backgroundColor),
49+
);
50+
},
51+
),
3852
],
3953
);
4054
},

0 commit comments

Comments
 (0)