feat: add an OpenContainer wrapper and remove an unneeded padding on app selector card

This commit is contained in:
Alberto Ponces 2022-09-01 11:16:14 +01:00
parent 0d14db41e1
commit 10a6ec2f1e
13 changed files with 46 additions and 49 deletions

View File

@ -81,9 +81,7 @@ class MyApp extends StatelessWidget {
}
class Navigation extends StatelessWidget {
const Navigation({
Key? key,
}) : super(key: key);
const Navigation({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {

View File

@ -73,7 +73,6 @@ class HomeView extends StatelessWidget {
const SizedBox(height: 10),
LatestCommitCard(
onPressed: () => model.updateManager(context),
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 23),
I18nText(

View File

@ -1,4 +1,3 @@
import 'package:animations/animations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart';
@ -10,6 +9,7 @@ import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_view.dart';
import 'package:revanced_manager/ui/widgets/patcherView/app_selector_card.dart';
import 'package:revanced_manager/ui/widgets/patcherView/patch_selector_card.dart';
import 'package:revanced_manager/ui/widgets/shared/open_container_wrapper.dart';
import 'package:stacked/stacked.dart';
class PatcherView extends StatelessWidget {
@ -23,14 +23,8 @@ class PatcherView extends StatelessWidget {
builder: (context, model, child) => Scaffold(
floatingActionButton: Visibility(
visible: model.showPatchButton(),
child: OpenContainer(
transitionDuration: const Duration(milliseconds: 400),
openBuilder: (_, openContainer) => const InstallerView(),
openColor: Theme.of(context).colorScheme.primary,
closedColor: Colors.transparent,
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
child: OpenContainerWrapper(
openBuilder: (_, __) => const InstallerView(),
closedBuilder: (_, openContainer) => FloatingActionButton.extended(
label: I18nText('patcherView.patchButton'),
icon: const Icon(Icons.build),
@ -80,18 +74,10 @@ class PatcherView extends StatelessWidget {
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
OpenContainer(
transitionDuration: const Duration(milliseconds: 400),
openBuilder: (_, openContainer) =>
const AppSelectorView(),
openColor: Theme.of(context).colorScheme.primary,
closedColor: Colors.transparent,
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
OpenContainerWrapper(
openBuilder: (_, __) => const AppSelectorView(),
closedBuilder: (_, openContainer) => AppSelectorCard(
onPressed: openContainer,
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(height: 16),
@ -99,19 +85,11 @@ class PatcherView extends StatelessWidget {
opacity: isDark
? (model.dimPatchesCard() ? 0.5 : 1)
: (model.dimPatchesCard() ? 0.75 : 1),
child: OpenContainer(
transitionDuration: const Duration(milliseconds: 400),
openBuilder: (_, openContainer) =>
const PatchesSelectorView(),
openColor: Theme.of(context).colorScheme.primary,
closedColor: Colors.transparent,
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
child: OpenContainerWrapper(
openBuilder: (_, __) => const PatchesSelectorView(),
closedBuilder: (_, openContainer) => PatchSelectorCard(
onPressed:
model.dimPatchesCard() ? () => {} : openContainer,
color: Theme.of(context).colorScheme.primary,
),
),
),

View File

@ -5,9 +5,7 @@ import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/application_item.dart';
class AvailableUpdatesCard extends StatelessWidget {
AvailableUpdatesCard({
Key? key,
}) : super(key: key);
AvailableUpdatesCard({Key? key}) : super(key: key);
final List<PatchedApplication> apps =
locator<HomeViewModel>().patchedUpdatableApps;

View File

@ -7,6 +7,7 @@ class DashboardChip extends StatelessWidget {
final String label;
final bool isSelected;
final Function(bool)? onSelected;
const DashboardChip({
Key? key,
required this.label,

View File

@ -6,9 +6,7 @@ import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/application_item.dart';
class InstalledAppsCard extends StatelessWidget {
InstalledAppsCard({
Key? key,
}) : super(key: key);
InstalledAppsCard({Key? key}) : super(key: key);
final List<PatchedApplication> apps =
locator<HomeViewModel>().patchedInstalledApps;

View File

@ -9,11 +9,10 @@ import 'package:revanced_manager/ui/widgets/shared/patch_text_button.dart';
class LatestCommitCard extends StatefulWidget {
final Function() onPressed;
final Color? color;
const LatestCommitCard({
Key? key,
required this.onPressed,
this.color = const Color(0xff1B222B),
}) : super(key: key);
@override
@ -28,7 +27,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: widget.color,
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
child: Row(

View File

@ -8,12 +8,10 @@ import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
class AppSelectorCard extends StatelessWidget {
final Function() onPressed;
final Color? color;
const AppSelectorCard({
Key? key,
required this.onPressed,
this.color = const Color(0xff1B222B),
}) : super(key: key);
@override
@ -24,13 +22,12 @@ class AppSelectorCard extends StatelessWidget {
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: color,
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
I18nText(
locator<PatcherViewModel>().selectedApp == null
? 'appSelectorCard.widgetTitle'

View File

@ -8,12 +8,10 @@ import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
class PatchSelectorCard extends StatelessWidget {
final Function() onPressed;
final Color? color;
const PatchSelectorCard({
Key? key,
required this.onPressed,
this.color = const Color(0xff1B222B),
}) : super(key: key);
@override
@ -24,7 +22,7 @@ class PatchSelectorCard extends StatelessWidget {
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: color,
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
child: Column(

View File

@ -5,6 +5,7 @@ import 'package:google_fonts/google_fonts.dart';
class MagiskButton extends StatelessWidget {
final Function() onPressed;
const MagiskButton({
Key? key,
required this.onPressed,

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
class CustomSwitch extends StatelessWidget {
final ValueChanged<bool> onChanged;
final bool value;
const CustomSwitch({
Key? key,
required this.onChanged,

View File

@ -0,0 +1,28 @@
import 'package:animations/animations.dart';
import 'package:flutter/material.dart';
class OpenContainerWrapper extends StatelessWidget {
final OpenContainerBuilder openBuilder;
final CloseContainerBuilder closedBuilder;
const OpenContainerWrapper({
Key? key,
required this.openBuilder,
required this.closedBuilder,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return OpenContainer(
openBuilder: openBuilder,
closedBuilder: closedBuilder,
transitionType: ContainerTransitionType.fade,
transitionDuration: const Duration(milliseconds: 400),
openColor: Theme.of(context).colorScheme.primary,
closedColor: Colors.transparent,
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
);
}
}

View File

@ -8,6 +8,7 @@ class PatchTextButton extends StatelessWidget {
final Function() onPressed;
final Color borderColor;
final Color backgroundColor;
const PatchTextButton({
Key? key,
required this.text,