feat: add Sliver App Bar to Home, Patcher, Installer and Settings views

This commit is contained in:
Alberto Ponces 2022-08-24 13:22:36 +01:00
parent e6b540d32b
commit 5041a30fb5
6 changed files with 444 additions and 364 deletions

View File

@ -59,8 +59,8 @@
}, },
"installerView": { "installerView": {
"widgetTitle": "Installer", "widgetTitle": "Installer",
"fabInstallButton": "Install", "installButton": "Install",
"fabOpenButton": "Open", "openButton": "Open",
"notificationTitle": "ReVanced Manager is patching", "notificationTitle": "ReVanced Manager is patching",
"notificationText": "Tap to return to the installer" "notificationText": "Tap to return to the installer"
}, },

View File

@ -21,25 +21,43 @@ class HomeView extends StatelessWidget {
onModelReady: (model) => model.initialize(), onModelReady: (model) => model.initialize(),
viewModelBuilder: () => locator<HomeViewModel>(), viewModelBuilder: () => locator<HomeViewModel>(),
builder: (context, model, child) => Scaffold( builder: (context, model, child) => Scaffold(
body: SafeArea( body: CustomScrollView(
child: SingleChildScrollView( slivers: <Widget>[
child: Padding( SliverAppBar(
padding: const EdgeInsets.symmetric(horizontal: 20.0), pinned: true,
child: Column( snap: false,
crossAxisAlignment: CrossAxisAlignment.start, floating: false,
children: [ expandedHeight: 100.0,
const SizedBox(height: 60), automaticallyImplyLeading: false,
I18nText( 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,
),
title: I18nText(
'homeView.widgetTitle', 'homeView.widgetTitle',
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
fontSize: 28, color: Theme.of(context).textTheme.headline5!.color,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
), ),
), ),
const SizedBox(height: 23), ),
),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
I18nText( I18nText(
'homeView.updatesSubtitle', 'homeView.updatesSubtitle',
child: Text( child: Text(
@ -99,6 +117,7 @@ class HomeView extends StatelessWidget {
), ),
), ),
), ),
],
), ),
), ),
); );

View File

@ -15,31 +15,49 @@ class InstallerView extends StatelessWidget {
viewModelBuilder: () => InstallerViewModel(), viewModelBuilder: () => InstallerViewModel(),
builder: (context, model, child) => WillPopScope( builder: (context, model, child) => WillPopScope(
child: Scaffold( child: Scaffold(
body: SafeArea( body: CustomScrollView(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20),
controller: model.scrollController, controller: model.scrollController,
child: Column( slivers: <Widget>[
crossAxisAlignment: CrossAxisAlignment.start, SliverAppBar(
children: <Widget>[ pinned: true,
const SizedBox(height: 60), snap: false,
Row( floating: false,
crossAxisAlignment: CrossAxisAlignment.start, expandedHeight: 100.0,
mainAxisAlignment: MainAxisAlignment.spaceBetween, automaticallyImplyLeading: false,
children: [ backgroundColor: MaterialStateColor.resolveWith(
Text( (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,
),
title: Text(
model.headerLogs, model.headerLogs,
style: GoogleFonts.inter( style: GoogleFonts.inter(
fontSize: 28, color: Theme.of(context).textTheme.headline5!.color,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
), ),
],
), ),
),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
Padding( Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.only(
vertical: 16.0, left: 4.0,
horizontal: 4.0, top: 0.0,
right: 4.0,
bottom: 16.0,
), ),
child: LinearProgressIndicator( child: LinearProgressIndicator(
color: Theme.of(context).colorScheme.secondary, color: Theme.of(context).colorScheme.secondary,
@ -63,8 +81,8 @@ class InstallerView extends StatelessWidget {
), ),
), ),
Padding( Padding(
padding: padding: const EdgeInsets.symmetric(
const EdgeInsets.symmetric(vertical: 16, horizontal: 0), vertical: 16, horizontal: 0),
child: Visibility( child: Visibility(
visible: !model.isPatching, visible: !model.isPatching,
child: Row( child: Row(
@ -84,8 +102,9 @@ class InstallerView extends StatelessWidget {
borderRadius: BorderRadius.circular(100), borderRadius: BorderRadius.circular(100),
side: BorderSide( side: BorderSide(
width: 1, width: 1,
color: color: Theme.of(context)
Theme.of(context).colorScheme.secondary, .colorScheme
.secondary,
), ),
), ),
), ),
@ -100,7 +119,9 @@ class InstallerView extends StatelessWidget {
), ),
backgroundColor: MaterialStateProperty.all( backgroundColor: MaterialStateProperty.all(
isDark isDark
? Theme.of(context).colorScheme.background ? Theme.of(context)
.colorScheme
.background
: Colors.white, : Colors.white,
), ),
foregroundColor: MaterialStateProperty.all( foregroundColor: MaterialStateProperty.all(
@ -132,8 +153,9 @@ class InstallerView extends StatelessWidget {
borderRadius: BorderRadius.circular(100), borderRadius: BorderRadius.circular(100),
side: BorderSide( side: BorderSide(
width: 1, width: 1,
color: color: Theme.of(context)
Theme.of(context).colorScheme.secondary, .colorScheme
.secondary,
), ),
), ),
), ),
@ -145,8 +167,8 @@ class InstallerView extends StatelessWidget {
), ),
), ),
child: I18nText(model.isInstalled child: I18nText(model.isInstalled
? 'installerView.fabOpenButton' ? 'installerView.openButton'
: 'installerView.fabInstallButton'), : 'installerView.installButton'),
), ),
], ],
), ),
@ -156,6 +178,8 @@ class InstallerView extends StatelessWidget {
), ),
), ),
), ),
],
),
), ),
onWillPop: () async { onWillPop: () async {
if (!model.isPatching) { if (!model.isPatching) {

View File

@ -122,7 +122,7 @@ class InstallerViewModel extends BaseViewModel {
resourcePatching = true; resourcePatching = true;
} }
await _patcherAPI.mergeIntegrations(mergeIntegrations); await _patcherAPI.mergeIntegrations(mergeIntegrations);
headerLogs = "Merging integrations"; headerLogs = 'Merging integrations';
await _patcherAPI.runPatcher( await _patcherAPI.runPatcher(
apkFilePath, apkFilePath,
_patches, _patches,

View File

@ -27,24 +27,43 @@ class PatcherView extends StatelessWidget {
foregroundColor: Colors.white, foregroundColor: Colors.white,
), ),
), ),
body: SafeArea( body: CustomScrollView(
child: SingleChildScrollView( slivers: <Widget>[
padding: const EdgeInsets.symmetric(horizontal: 20.0), SliverAppBar(
child: Column( pinned: true,
crossAxisAlignment: CrossAxisAlignment.start, snap: false,
children: [ floating: false,
const SizedBox(height: 60), expandedHeight: 100.0,
I18nText( 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,
),
title: I18nText(
'patcherView.widgetTitle', 'patcherView.widgetTitle',
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
fontSize: 28, color: Theme.of(context).textTheme.headline5!.color,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
), ),
), ),
const SizedBox(height: 23), ),
),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
AppSelectorCard( AppSelectorCard(
onPressed: model.navigateToAppSelector, onPressed: model.navigateToAppSelector,
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
@ -65,6 +84,8 @@ class PatcherView extends StatelessWidget {
), ),
), ),
), ),
],
),
), ),
); );
} }

View File

@ -26,28 +26,43 @@ class SettingsView extends StatelessWidget {
viewModelBuilder: () => SettingsViewModel(), viewModelBuilder: () => SettingsViewModel(),
onModelReady: (model) => model.initialize(), onModelReady: (model) => model.initialize(),
builder: (context, SettingsViewModel model, child) => Scaffold( builder: (context, SettingsViewModel model, child) => Scaffold(
body: SingleChildScrollView( body: CustomScrollView(
child: SafeArea( slivers: <Widget>[
child: Padding( SliverAppBar(
padding: const EdgeInsets.symmetric(horizontal: 12.0), pinned: true,
child: Column( snap: false,
crossAxisAlignment: CrossAxisAlignment.start, floating: false,
children: <Widget>[ expandedHeight: 100.0,
const SizedBox(height: 60), automaticallyImplyLeading: false,
Padding( backgroundColor: MaterialStateColor.resolveWith(
padding: const EdgeInsets.symmetric(horizontal: 8.0), (states) => states.contains(MaterialState.scrolledUnder)
child: I18nText( ? isDark
'settingsView.widgetTitle', ? 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,
),
title: I18nText(
'homeView.widgetTitle',
child: Text( child: Text(
'', '',
style: GoogleFonts.inter( style: GoogleFonts.inter(
fontSize: 28, color: Theme.of(context).textTheme.headline5!.color,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
), ),
), ),
), ),
const SizedBox(height: 12), ),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
SettingsSwitchItem( SettingsSwitchItem(
title: 'settingsView.themeLabel', title: 'settingsView.themeLabel',
subtitle: 'settingsView.themeHint', subtitle: 'settingsView.themeHint',
@ -154,6 +169,7 @@ class SettingsView extends StatelessWidget {
), ),
), ),
), ),
],
), ),
), ),
); );