feat: improve app theming code and add Material You (#58)

This commit is contained in:
Alberto Ponces
2022-09-05 03:32:36 +01:00
committed by GitHub
parent 35d334ea1f
commit 5404208562
44 changed files with 627 additions and 854 deletions

View File

@ -4,6 +4,7 @@ import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/application_item.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
class AvailableUpdatesCard extends StatelessWidget {
AvailableUpdatesCard({Key? key}) : super(key: key);
@ -14,28 +15,18 @@ class AvailableUpdatesCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return apps.isEmpty
? Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
? CustomCard(
child: Center(
child: Column(
children: <Widget>[
Icon(
Icons.update_disabled,
size: 40,
color: Theme.of(context).colorScheme.secondary,
),
const Icon(Icons.update_disabled, size: 40),
const SizedBox(height: 16),
I18nText(
'homeView.noUpdates',
child: Text(
'',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1!.copyWith(
color: Theme.of(context).colorScheme.secondary),
style: Theme.of(context).textTheme.subtitle1!,
),
)
],

View File

@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
class DashboardChip extends StatelessWidget {
final Widget label;
final bool isSelected;
final Function(bool)? onSelected;
const DashboardChip({
Key? key,
required this.label,
required this.isSelected,
this.onSelected,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return RawChip(
showCheckmark: false,
label: label,
selected: isSelected,
labelStyle: Theme.of(context).textTheme.subtitle2!.copyWith(
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold,
),
backgroundColor: Colors.transparent,
selectedColor: Theme.of(context).colorScheme.secondaryContainer,
padding: const EdgeInsets.all(10),
onSelected: onSelected,
);
}
}

View File

@ -1,52 +0,0 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/theme.dart';
class DashboardChip extends StatelessWidget {
final Widget label;
final bool isSelected;
final Function(bool)? onSelected;
const DashboardChip({
Key? key,
required this.label,
required this.isSelected,
this.onSelected,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return RawChip(
showCheckmark: false,
label: label,
selected: isSelected,
labelStyle: GoogleFonts.inter(
color: isSelected
? isDark
? const Color(0xff95C0FE)
: Theme.of(context).colorScheme.secondary
: isDark
? Colors.grey
: Colors.grey[700],
fontWeight: FontWeight.w500,
),
backgroundColor:
isDark ? Theme.of(context).colorScheme.background : Colors.white,
selectedColor: const Color.fromRGBO(118, 155, 209, 0.42),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
width: 1,
color: isDark
? isSelected
? const Color.fromRGBO(118, 155, 209, 0.42)
: Colors.grey
: isSelected
? const Color.fromRGBO(118, 155, 209, 0.42)
: Colors.grey,
),
),
onSelected: onSelected,
);
}
}

View File

@ -5,6 +5,7 @@ import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/application_item.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
class InstalledAppsCard extends StatelessWidget {
InstalledAppsCard({Key? key}) : super(key: key);
@ -15,28 +16,18 @@ class InstalledAppsCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return apps.isEmpty
? Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
? CustomCard(
child: Center(
child: Column(
children: <Widget>[
Icon(
Icons.file_download_off,
size: 40,
color: Theme.of(context).colorScheme.secondary,
),
const Icon(Icons.file_download_off, size: 40),
const SizedBox(height: 16),
I18nText(
'homeView.noInstallations',
child: Text(
'',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1!.copyWith(
color: Theme.of(context).colorScheme.secondary),
style: Theme.of(context).textTheme.subtitle1!,
),
)
],

View File

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/constants.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/patch_text_button.dart';
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
class LatestCommitCard extends StatefulWidget {
final Function() onPressed;
@ -24,12 +24,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 20),
return CustomCard(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
@ -40,11 +35,9 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
children: <Widget>[
I18nText(
'latestCommitCard.patcherLabel',
child: Text(
child: const Text(
'',
style: GoogleFonts.roboto(
fontWeight: FontWeight.w700,
),
style: TextStyle(fontWeight: FontWeight.bold),
),
),
FutureBuilder<String>(
@ -60,7 +53,6 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
context,
'latestCommitCard.loadingLabel',
),
style: kRobotoTextStyle,
),
),
],
@ -70,28 +62,20 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
children: <Widget>[
I18nText(
'latestCommitCard.managerLabel',
child: Text(
child: const Text(
'',
style: GoogleFonts.roboto(
fontWeight: FontWeight.w700,
),
style: TextStyle(fontWeight: FontWeight.bold),
),
),
FutureBuilder<String>(
future: _githubAPI.latestCommitTime(ghOrg, managerRepo),
builder: (context, snapshot) => Text(
snapshot.hasData && snapshot.data!.isNotEmpty
? FlutterI18n.translate(
context,
'latestCommitCard.timeagoLabel',
translationParams: {'time': snapshot.data!},
)
: FlutterI18n.translate(
context,
'latestCommitCard.loadingLabel',
),
style: kRobotoTextStyle,
),
builder: (context, snapshot) =>
snapshot.hasData && snapshot.data!.isNotEmpty
? I18nText(
'latestCommitCard.timeagoLabel',
translationParams: {'time': snapshot.data!},
)
: I18nText('latestCommitCard.loadingLabel'),
),
],
),
@ -101,17 +85,13 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
future: locator<HomeViewModel>().hasManagerUpdates(),
initialData: false,
builder: (context, snapshot) => Opacity(
opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.5,
child: PatchTextButton(
text: FlutterI18n.translate(
context,
'latestCommitCard.updateButton',
),
opacity: snapshot.hasData && snapshot.data! ? 1.0 : 1.0,
child: CustomMaterialButton(
isExpanded: false,
label: I18nText('latestCommitCard.updateButton'),
onPressed: snapshot.hasData && snapshot.data!
? widget.onPressed
: () => {},
backgroundColor: Theme.of(context).colorScheme.secondary,
borderColor: Theme.of(context).colorScheme.secondary,
),
),
),