2022-08-13 11:56:30 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
2022-08-23 20:13:06 +02:00
|
|
|
import 'package:revanced_manager/theme.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-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>[
|
|
|
|
SliverAppBar(
|
|
|
|
pinned: true,
|
|
|
|
snap: false,
|
|
|
|
floating: false,
|
|
|
|
expandedHeight: 100.0,
|
|
|
|
automaticallyImplyLeading: false,
|
|
|
|
backgroundColor: MaterialStateColor.resolveWith(
|
|
|
|
(states) => states.contains(MaterialState.scrolledUnder)
|
|
|
|
? isDark
|
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
: Theme.of(context)
|
|
|
|
.navigationBarTheme
|
|
|
|
.backgroundColor!
|
|
|
|
: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
),
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
|
|
titlePadding: const EdgeInsets.symmetric(
|
|
|
|
vertical: 23.0,
|
|
|
|
horizontal: 20.0,
|
2022-08-15 04:31:36 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
title: Text(
|
|
|
|
model.headerLogs,
|
|
|
|
style: GoogleFonts.inter(
|
|
|
|
color: Theme.of(context).textTheme.headline5!.color,
|
|
|
|
fontWeight: FontWeight.w500,
|
2022-08-15 04:31:36 +02:00
|
|
|
),
|
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
SliverPadding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
|
|
sliver: SliverList(
|
|
|
|
delegate: SliverChildListDelegate.fixed(
|
|
|
|
<Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 4.0,
|
|
|
|
top: 0.0,
|
|
|
|
right: 4.0,
|
|
|
|
bottom: 16.0,
|
|
|
|
),
|
|
|
|
child: LinearProgressIndicator(
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
value: model.progress,
|
|
|
|
),
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
Container(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
width: double.infinity,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2022-09-01 02:25:19 +02:00
|
|
|
borderRadius: BorderRadius.circular(12),
|
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,
|
|
|
|
children: [
|
2022-08-30 15:53:37 +02:00
|
|
|
CustomMaterialButton(
|
2022-08-31 10:36:36 +02:00
|
|
|
text: 'installerView.shareButton',
|
2022-08-30 15:53:37 +02:00
|
|
|
isFilled: false,
|
2022-08-24 14:22:36 +02:00
|
|
|
onPressed: () => model.shareResult(),
|
2022-08-23 20:13:06 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
const SizedBox(width: 16),
|
2022-08-30 15:53:37 +02:00
|
|
|
CustomMaterialButton(
|
|
|
|
text: model.isInstalled
|
|
|
|
? 'installerView.openButton'
|
|
|
|
: 'installerView.installButton',
|
|
|
|
isFilled: true,
|
|
|
|
isExpanded: true,
|
2022-08-24 14:22:36 +02:00
|
|
|
onPressed: () {
|
|
|
|
if (model.isInstalled) {
|
|
|
|
model.openApp();
|
2022-08-31 10:33:32 +02:00
|
|
|
model.cleanPatcher();
|
2022-08-24 14:22:36 +02:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
} else {
|
|
|
|
model.installResult();
|
|
|
|
}
|
|
|
|
},
|
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
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|