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-09-16 00:16:46 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/installerView/gradient_progress_indicator.dart';
|
2022-09-05 04:32:36 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.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(
|
2023-01-30 13:35:06 +01:00
|
|
|
onViewModelReady: (model) => model.initialize(context),
|
2022-08-18 16:33:33 +02:00
|
|
|
viewModelBuilder: () => InstallerViewModel(),
|
2022-08-15 04:31:36 +02:00
|
|
|
builder: (context, model, child) => WillPopScope(
|
2022-09-24 09:23:46 +02:00
|
|
|
child: SafeArea(
|
|
|
|
top: false,
|
2023-05-10 12:18:51 +02:00
|
|
|
bottom: false,
|
2022-09-24 09:23:46 +02:00
|
|
|
child: Scaffold(
|
2023-08-10 14:02:30 +02:00
|
|
|
floatingActionButton: Visibility(
|
2023-08-28 18:05:30 +02:00
|
|
|
visible: !model.isPatching && !model.hasErrors,
|
2023-08-10 14:02:30 +02:00
|
|
|
child: FloatingActionButton.extended(
|
2023-09-03 16:48:28 +02:00
|
|
|
label: I18nText(
|
|
|
|
model.isInstalled
|
|
|
|
? 'installerView.openButton'
|
|
|
|
: 'installerView.installButton',
|
|
|
|
),
|
|
|
|
icon: model.isInstalled
|
|
|
|
? const Icon(Icons.open_in_new)
|
|
|
|
: const Icon(Icons.file_download_outlined),
|
|
|
|
onPressed: model.isInstalled
|
|
|
|
? () => {
|
|
|
|
model.openApp(),
|
|
|
|
model.cleanPatcher(),
|
|
|
|
Navigator.of(context).pop(),
|
|
|
|
}
|
|
|
|
: () => model.installTypeDialog(context),
|
2023-08-24 14:00:50 +02:00
|
|
|
elevation: 0,
|
2023-08-10 14:02:30 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
floatingActionButtonLocation:
|
|
|
|
FloatingActionButtonLocation.endContained,
|
|
|
|
bottomNavigationBar: Visibility(
|
|
|
|
visible: !model.isPatching,
|
|
|
|
child: BottomAppBar(
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Visibility(
|
|
|
|
visible: !model.hasErrors,
|
|
|
|
child: IconButton.filledTonal(
|
|
|
|
tooltip: FlutterI18n.translate(
|
2023-08-12 09:33:15 +02:00
|
|
|
context,
|
|
|
|
'installerView.exportApkButtonTooltip',
|
|
|
|
),
|
2023-08-10 14:02:30 +02:00
|
|
|
icon: const Icon(Icons.save),
|
|
|
|
onPressed: () => model.onButtonPressed(0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
IconButton.filledTonal(
|
|
|
|
tooltip: FlutterI18n.translate(
|
2023-08-12 09:33:15 +02:00
|
|
|
context,
|
|
|
|
'installerView.exportLogButtonTooltip',
|
|
|
|
),
|
2023-08-10 14:02:30 +02:00
|
|
|
icon: const Icon(Icons.post_add),
|
|
|
|
onPressed: () => model.onButtonPressed(1),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-09-24 09:23:46 +02:00
|
|
|
body: CustomScrollView(
|
|
|
|
controller: model.scrollController,
|
|
|
|
slivers: <Widget>[
|
|
|
|
CustomSliverAppBar(
|
|
|
|
title: Text(
|
|
|
|
model.headerLogs,
|
|
|
|
style: GoogleFonts.inter(
|
2023-02-19 04:16:49 +01:00
|
|
|
color: Theme.of(context).textTheme.titleLarge!.color,
|
2022-09-24 09:23:46 +02:00
|
|
|
),
|
2023-08-03 23:38:38 +02:00
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2022-08-15 04:31:36 +02:00
|
|
|
),
|
2022-09-24 09:23:46 +02:00
|
|
|
onBackButtonPressed: () => model.onWillPop(context),
|
|
|
|
bottom: PreferredSize(
|
2023-01-30 13:35:06 +01:00
|
|
|
preferredSize: const Size(double.infinity, 1.0),
|
|
|
|
child: GradientProgressIndicator(progress: model.progress),
|
|
|
|
),
|
2022-09-24 09:23:46 +02:00
|
|
|
),
|
|
|
|
SliverPadding(
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
sliver: SliverList(
|
|
|
|
delegate: SliverChildListDelegate.fixed(
|
|
|
|
<Widget>[
|
|
|
|
CustomCard(
|
|
|
|
child: Text(
|
|
|
|
model.logs,
|
|
|
|
style: GoogleFonts.jetBrainsMono(
|
|
|
|
fontSize: 13,
|
|
|
|
height: 1.5,
|
2022-09-06 15:40:49 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-09-24 09:23:46 +02:00
|
|
|
],
|
2022-09-06 15:40:49 +02:00
|
|
|
),
|
|
|
|
),
|
2022-09-12 12:14:54 +02:00
|
|
|
),
|
2022-09-24 09:23:46 +02:00
|
|
|
],
|
|
|
|
),
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
),
|
2022-09-19 18:40:06 +02:00
|
|
|
onWillPop: () => model.onWillPop(context),
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|