Add PrimaryButton component (#221)

This commit is contained in:
Ian VanSchooten 2025-01-16 10:59:21 -05:00 committed by GitHub
parent 991837676a
commit a28b922494
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 2 deletions

View file

@ -0,0 +1,28 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class PrimaryButton extends StatelessWidget {
const PrimaryButton({Key? key, required this.child, this.onPressed}) : super(key: key);
final Widget child;
final GestureTapCallback? onPressed;
@override
Widget build(BuildContext context) {
if (Platform.isAndroid) {
return FilledButton(
onPressed: onPressed,
child: child,
style: FilledButton.styleFrom(backgroundColor: Theme.of(context).colorScheme.primary));
} else {
// Workaround for https://github.com/flutter/flutter/issues/161590
final themeData = CupertinoTheme.of(context);
return CupertinoTheme(
data: themeData.copyWith(primaryColor: CupertinoColors.white),
child: CupertinoButton(
child: child, onPressed: onPressed, color: CupertinoColors.secondaryLabel.resolveFrom(context)));
}
}
}

View file

@ -15,6 +15,7 @@ import 'package:mobile_nebula/screens/siteConfig/ScanQRScreen.dart';
import 'package:mobile_nebula/services/share.dart';
import 'package:mobile_nebula/services/utils.dart';
import '../../components/buttons/PrimaryButton.dart';
import 'CertificateDetailsScreen.dart';
class CertificateResult {
@ -152,9 +153,8 @@ class _AddCertificateScreenState extends State<AddCertificateScreen> {
padding: EdgeInsets.only(top: 20, bottom: 10, left: 10, right: 10),
child: SizedBox(
width: double.infinity,
child: PlatformElevatedButton(
child: PrimaryButton(
child: Text('Show/Import Private Key'),
color: CupertinoColors.secondaryLabel.resolveFrom(context),
onPressed: () => Utils.confirmDelete(context, 'Show/Import Private Key?', () {
setState(() {
showKey = true;