feat: custom buttons for installer screen.

This commit is contained in:
Aunali321 2022-08-30 19:23:37 +05:30
parent 1920221b19
commit c0b164ec26
3 changed files with 79 additions and 71 deletions

View file

@ -61,6 +61,7 @@
"widgetTitle": "Installer",
"installButton": "Install",
"openButton": "Open",
"shareButton": "Share file",
"notificationTitle": "ReVanced Manager is patching",
"notificationText": "Tap to return to the installer"
},

View file

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.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/widgets/installerView/custom_material_button.dart';
import 'package:stacked/stacked.dart';
class InstallerView extends StatelessWidget {
@ -88,51 +88,18 @@ class InstallerView extends StatelessWidget {
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,
),
),
CustomMaterialButton(
text: "installerView.shareButton",
isFilled: false,
onPressed: () => model.shareResult(),
child: I18nText("Share file"),
),
const SizedBox(width: 16),
TextButton(
CustomMaterialButton(
text: model.isInstalled
? 'installerView.openButton'
: 'installerView.installButton',
isFilled: true,
isExpanded: true,
onPressed: () {
if (model.isInstalled) {
model.openApp();
@ -141,34 +108,6 @@ class InstallerView extends StatelessWidget {
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.openButton'
: 'installerView.installButton'),
),
],
),

View file

@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/widgets/I18nText.dart';
import 'package:revanced_manager/theme.dart';
class CustomMaterialButton extends StatelessWidget {
final String text;
final bool isFilled;
final bool isExpanded;
final Function()? onPressed;
const CustomMaterialButton({
Key? key,
required this.text,
this.isFilled = true,
this.isExpanded = false,
required this.onPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
isExpanded
? const EdgeInsets.symmetric(
horizontal: 24,
vertical: 12,
)
: 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: isFilled
? Colors.transparent
: Theme.of(context).iconTheme.color!.withOpacity(0.4),
width: 1,
),
),
backgroundColor: MaterialStateProperty.all(
isFilled
? Theme.of(context).colorScheme.secondary
: isDark
? Theme.of(context).colorScheme.background
: Colors.white,
),
foregroundColor: MaterialStateProperty.all(
isFilled
? Theme.of(context).colorScheme.background
: Theme.of(context).colorScheme.secondary,
),
),
onPressed: onPressed,
child: I18nText(text),
);
}
}