mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-03 15:24:25 +02:00
feat: improve installer screen.
This commit is contained in:
parent
06b90244b4
commit
e6b540d32b
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:revanced_manager/theme.dart';
|
||||||
import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
|
|
||||||
@ -14,50 +15,23 @@ class InstallerView extends StatelessWidget {
|
|||||||
viewModelBuilder: () => InstallerViewModel(),
|
viewModelBuilder: () => InstallerViewModel(),
|
||||||
builder: (context, model, child) => WillPopScope(
|
builder: (context, model, child) => WillPopScope(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
floatingActionButton: Visibility(
|
|
||||||
visible: !model.isPatching,
|
|
||||||
child: FloatingActionButton.extended(
|
|
||||||
onPressed: () {
|
|
||||||
if (model.isInstalled) {
|
|
||||||
model.openApp();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
} else {
|
|
||||||
model.installResult();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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(
|
body: SafeArea(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
controller: model.scrollController,
|
controller: model.scrollController,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
const SizedBox(height: 60),
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
I18nText(
|
Text(
|
||||||
'installerView.widgetTitle',
|
model.headerLogs,
|
||||||
child: Text(
|
style: GoogleFonts.inter(
|
||||||
'',
|
fontSize: 28,
|
||||||
style: Theme.of(context).textTheme.headline5,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: !model.isPatching,
|
|
||||||
child: IconButton(
|
|
||||||
icon: const Icon(Icons.share),
|
|
||||||
onPressed: () => model.shareResult(),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -88,6 +62,96 @@ class InstallerView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(vertical: 16, horizontal: 0),
|
||||||
|
child: Visibility(
|
||||||
|
visible: !model.isPatching,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
//TODO: Move to separate file
|
||||||
|
TextButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 20,
|
||||||
|
vertical: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shape: MaterialStateProperty.all(
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
side: BorderSide(
|
||||||
|
width: 1,
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
side: MaterialStateProperty.all(
|
||||||
|
BorderSide(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.iconTheme
|
||||||
|
.color!
|
||||||
|
.withOpacity(0.4),
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor: MaterialStateProperty.all(
|
||||||
|
isDark
|
||||||
|
? Theme.of(context).colorScheme.background
|
||||||
|
: Colors.white,
|
||||||
|
),
|
||||||
|
foregroundColor: MaterialStateProperty.all(
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () => model.shareResult(),
|
||||||
|
child: I18nText("Share file"),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (model.isInstalled) {
|
||||||
|
model.openApp();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
} else {
|
||||||
|
model.installResult();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(
|
||||||
|
const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shape: MaterialStateProperty.all(
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
side: BorderSide(
|
||||||
|
width: 1,
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor: MaterialStateProperty.all(
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
foregroundColor: MaterialStateProperty.all(
|
||||||
|
Theme.of(context).colorScheme.background,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: I18nText(model.isInstalled
|
||||||
|
? 'installerView.fabOpenButton'
|
||||||
|
: 'installerView.fabInstallButton'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -22,6 +22,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
);
|
);
|
||||||
double? progress = 0.0;
|
double? progress = 0.0;
|
||||||
String logs = '';
|
String logs = '';
|
||||||
|
String headerLogs = '';
|
||||||
bool isPatching = false;
|
bool isPatching = false;
|
||||||
bool isInstalled = false;
|
bool isInstalled = false;
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
String apkFilePath = _app!.apkFilePath;
|
String apkFilePath = _app!.apkFilePath;
|
||||||
try {
|
try {
|
||||||
updateLog('Initializing installer');
|
updateLog('Initializing installer');
|
||||||
|
headerLogs = 'Initializing';
|
||||||
if (_app!.isRooted && !_app!.isFromStorage) {
|
if (_app!.isRooted && !_app!.isFromStorage) {
|
||||||
updateLog('Checking if an old patched version exists');
|
updateLog('Checking if an old patched version exists');
|
||||||
bool oldExists = await _patcherAPI.checkOldPatch(_app!);
|
bool oldExists = await _patcherAPI.checkOldPatch(_app!);
|
||||||
@ -120,6 +122,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
resourcePatching = true;
|
resourcePatching = true;
|
||||||
}
|
}
|
||||||
await _patcherAPI.mergeIntegrations(mergeIntegrations);
|
await _patcherAPI.mergeIntegrations(mergeIntegrations);
|
||||||
|
headerLogs = "Merging integrations";
|
||||||
await _patcherAPI.runPatcher(
|
await _patcherAPI.runPatcher(
|
||||||
apkFilePath,
|
apkFilePath,
|
||||||
_patches,
|
_patches,
|
||||||
@ -128,6 +131,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
);
|
);
|
||||||
} on Exception {
|
} on Exception {
|
||||||
updateLog('An error occurred! Aborting');
|
updateLog('An error occurred! Aborting');
|
||||||
|
headerLogs = 'Aborting...';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updateLog('No app or patches selected! Aborting');
|
updateLog('No app or patches selected! Aborting');
|
||||||
@ -144,6 +148,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
updateLog(_app!.isRooted
|
updateLog(_app!.isRooted
|
||||||
? 'Installing patched file using root method'
|
? 'Installing patched file using root method'
|
||||||
: 'Installing patched file using nonroot method');
|
: 'Installing patched file using nonroot method');
|
||||||
|
headerLogs = 'Installing...';
|
||||||
isInstalled = await _patcherAPI.installPatchedFile(_app!);
|
isInstalled = await _patcherAPI.installPatchedFile(_app!);
|
||||||
if (isInstalled) {
|
if (isInstalled) {
|
||||||
updateLog('Done');
|
updateLog('Done');
|
||||||
@ -152,6 +157,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
await saveApp();
|
await saveApp();
|
||||||
} else {
|
} else {
|
||||||
updateLog('An error occurred! Aborting');
|
updateLog('An error occurred! Aborting');
|
||||||
|
headerLogs = 'Aborting...';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,16 @@ class SettingsView extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 60),
|
const SizedBox(height: 60),
|
||||||
I18nText(
|
Padding(
|
||||||
'settingsView.widgetTitle',
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
child: Text(
|
child: I18nText(
|
||||||
'',
|
'settingsView.widgetTitle',
|
||||||
style: GoogleFonts.inter(
|
child: Text(
|
||||||
fontSize: 28,
|
'',
|
||||||
fontWeight: FontWeight.w500,
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 28,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user