2022-08-13 11:56:30 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-02 15:35:25 +02:00
|
|
|
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';
|
2022-08-30 15:53:37 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
2022-09-05 04:32:36 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
2022-09-06 15:40:49 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_popup_menu.dart';
|
2022-09-02 15:35:25 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
|
2022-08-13 11:56:30 +02:00
|
|
|
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(
|
2022-08-24 14:22:36 +02:00
|
|
|
body: CustomScrollView(
|
|
|
|
controller: model.scrollController,
|
|
|
|
slivers: <Widget>[
|
2022-09-02 15:35:25 +02:00
|
|
|
CustomSliverAppBar(
|
|
|
|
title: Text(
|
|
|
|
model.headerLogs,
|
|
|
|
style: GoogleFonts.inter(
|
2022-09-05 04:32:36 +02:00
|
|
|
color: Theme.of(context).textTheme.headline6!.color,
|
2022-08-15 04:31:36 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
2022-09-06 15:40:49 +02:00
|
|
|
actions: <Widget>[
|
|
|
|
Visibility(
|
|
|
|
visible: !model.isPatching,
|
|
|
|
child: CustomPopupMenu(
|
|
|
|
onSelected: (value) => model.onMenuSelection(value),
|
|
|
|
children: {
|
|
|
|
0: I18nText(
|
|
|
|
'installerView.shareApkMenuOption',
|
|
|
|
child: const Text(
|
|
|
|
'',
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
1: I18nText(
|
|
|
|
'installerView.shareLogMenuOption',
|
|
|
|
child: const Text(
|
|
|
|
'',
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-09-02 01:30:41 +02:00
|
|
|
bottom: PreferredSize(
|
|
|
|
preferredSize: const Size(double.infinity, 1.0),
|
|
|
|
child: LinearProgressIndicator(
|
2022-09-05 04:32:36 +02:00
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2022-09-07 13:01:04 +02:00
|
|
|
backgroundColor: Theme.of(context).colorScheme.secondary,
|
2022-09-02 01:30:41 +02:00
|
|
|
value: model.progress,
|
|
|
|
),
|
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
|
|
|
SliverPadding(
|
2022-09-02 01:30:41 +02:00
|
|
|
padding: const EdgeInsets.all(20.0),
|
2022-08-24 14:22:36 +02:00
|
|
|
sliver: SliverList(
|
|
|
|
delegate: SliverChildListDelegate.fixed(
|
|
|
|
<Widget>[
|
2022-09-05 04:32:36 +02:00
|
|
|
CustomCard(
|
2022-08-24 14:22:36 +02:00
|
|
|
child: Text(
|
|
|
|
model.logs,
|
|
|
|
style: GoogleFonts.jetBrainsMono(
|
|
|
|
fontSize: 13,
|
|
|
|
height: 1.5,
|
2022-08-23 20:13:06 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
2022-08-31 10:33:32 +02:00
|
|
|
vertical: 16,
|
|
|
|
horizontal: 0,
|
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
child: Visibility(
|
|
|
|
visible: !model.isPatching,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-09-06 15:40:49 +02:00
|
|
|
Visibility(
|
|
|
|
visible: model.isInstalled,
|
|
|
|
child: CustomMaterialButton(
|
|
|
|
label: I18nText('installerView.openButton'),
|
|
|
|
isExpanded: true,
|
|
|
|
onPressed: () {
|
2022-08-24 14:22:36 +02:00
|
|
|
model.openApp();
|
2022-08-31 10:33:32 +02:00
|
|
|
model.cleanPatcher();
|
2022-08-24 14:22:36 +02:00
|
|
|
Navigator.of(context).pop();
|
2022-09-06 15:40:49 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
visible: !model.isInstalled,
|
|
|
|
child: CustomMaterialButton(
|
|
|
|
isFilled: false,
|
|
|
|
label:
|
|
|
|
I18nText('installerView.installButton'),
|
|
|
|
isExpanded: true,
|
|
|
|
onPressed: () => model.installResult(false),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
visible: !model.isInstalled,
|
|
|
|
child: const SizedBox(
|
|
|
|
width: 16,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Visibility(
|
|
|
|
visible: !model.isInstalled,
|
|
|
|
child: CustomMaterialButton(
|
|
|
|
label: I18nText(
|
|
|
|
'installerView.installRootButton'),
|
|
|
|
isExpanded: true,
|
|
|
|
onPressed: () => model.installResult(true),
|
|
|
|
),
|
2022-08-23 20:13:06 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
],
|
2022-08-23 20:13:06 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
2022-08-23 20:13:06 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
],
|
2022-08-23 20:13:06 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
],
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
),
|
2022-08-15 04:31:36 +02:00
|
|
|
onWillPop: () async {
|
|
|
|
if (!model.isPatching) {
|
2022-08-22 02:31:27 +02:00
|
|
|
model.cleanPatcher();
|
2022-08-15 04:31:36 +02:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|