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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 627 additions and 854 deletions

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,
),
),
),