2022-08-13 11:56:30 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
2022-08-13 11:56:30 +02:00
|
|
|
import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
|
|
|
|
import 'package:stacked/stacked.dart';
|
|
|
|
|
|
|
|
class InstallerView extends StatelessWidget {
|
2022-08-22 01:49:09 +02:00
|
|
|
const InstallerView({Key? key}) : super(key: key);
|
2022-08-13 11:56:30 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ViewModelBuilder<InstallerViewModel>.reactive(
|
2022-08-18 16:33:33 +02:00
|
|
|
onModelReady: (model) => model.initialize(context),
|
|
|
|
viewModelBuilder: () => InstallerViewModel(),
|
2022-08-15 04:31:36 +02:00
|
|
|
builder: (context, model, child) => WillPopScope(
|
|
|
|
child: Scaffold(
|
|
|
|
floatingActionButton: Visibility(
|
2022-08-17 13:48:03 +02:00
|
|
|
visible: !model.isPatching,
|
2022-08-15 04:31:36 +02:00
|
|
|
child: FloatingActionButton.extended(
|
2022-08-22 01:54:58 +02:00
|
|
|
onPressed: () {
|
|
|
|
if (model.isInstalled) {
|
|
|
|
model.openApp();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
} else {
|
|
|
|
model.installResult();
|
|
|
|
}
|
|
|
|
},
|
2022-08-15 04:31:36 +02:00
|
|
|
label: I18nText(model.isInstalled
|
|
|
|
? 'installerView.fabOpenButton'
|
|
|
|
: 'installerView.fabInstallButton'),
|
|
|
|
icon: model.isInstalled
|
|
|
|
? const Icon(Icons.open_in_new)
|
|
|
|
: const Icon(Icons.install_mobile),
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.secondary,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: SafeArea(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
2022-08-22 01:49:09 +02:00
|
|
|
controller: model.scrollController,
|
2022-08-15 04:31:36 +02:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
I18nText(
|
|
|
|
'installerView.widgetTitle',
|
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: Theme.of(context).textTheme.headline5,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Visibility(
|
2022-08-17 13:48:03 +02:00
|
|
|
visible: !model.isPatching,
|
2022-08-15 04:31:36 +02:00
|
|
|
child: IconButton(
|
|
|
|
icon: const Icon(Icons.share),
|
|
|
|
onPressed: () => model.shareResult(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
vertical: 16.0,
|
|
|
|
horizontal: 4.0,
|
|
|
|
),
|
|
|
|
child: LinearProgressIndicator(
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
value: model.progress,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
width: double.infinity,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
2022-08-22 01:49:09 +02:00
|
|
|
child: Text(
|
2022-08-15 04:31:36 +02:00
|
|
|
model.logs,
|
2022-08-16 15:06:56 +02:00
|
|
|
style: GoogleFonts.jetBrainsMono(
|
2022-08-17 18:07:00 +02:00
|
|
|
fontSize: 13,
|
2022-08-15 04:31:36 +02:00
|
|
|
height: 1.5,
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-08-15 04:31:36 +02:00
|
|
|
],
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-08-15 04:31:36 +02:00
|
|
|
onWillPop: () async {
|
|
|
|
if (!model.isPatching) {
|
|
|
|
model.cleanWorkplace();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|