revanced-manager/lib/ui/views/installer/installer_view.dart

119 lines
4.5 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart';
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';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.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);
@override
Widget build(BuildContext context) {
return ViewModelBuilder<InstallerViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
2022-08-18 16:33:33 +02:00
viewModelBuilder: () => InstallerViewModel(),
builder: (context, model, child) => WillPopScope(
2022-09-24 09:23:46 +02:00
child: SafeArea(
top: false,
bottom: false,
2022-09-24 09:23:46 +02:00
child: Scaffold(
floatingActionButton: Visibility(
2023-08-28 18:05:30 +02:00
visible: !model.isPatching && !model.hasErrors,
child: FloatingActionButton.extended(
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),
elevation: 0,
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.endContained,
bottomNavigationBar: Visibility(
visible: !model.isPatching,
child: BottomAppBar(
child: Row(
children: <Widget>[
Visibility(
visible: !model.hasErrors,
child: IconButton.filledTonal(
tooltip: FlutterI18n.translate(
context,
'installerView.exportApkButtonTooltip',
),
icon: const Icon(Icons.save),
onPressed: () => model.onButtonPressed(0),
),
),
IconButton.filledTonal(
tooltip: FlutterI18n.translate(
context,
'installerView.exportLogButtonTooltip',
),
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(
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-09-24 09:23:46 +02:00
onBackButtonPressed: () => model.onWillPop(context),
bottom: PreferredSize(
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-24 09:23:46 +02:00
],
),
),
),
2022-09-24 09:23:46 +02:00
],
),
),
),
onWillPop: () => model.onWillPop(context),
),
);
}
}