diff --git a/lib/components/buttons/PrimaryButton.dart b/lib/components/buttons/PrimaryButton.dart new file mode 100644 index 0000000..349b4c0 --- /dev/null +++ b/lib/components/buttons/PrimaryButton.dart @@ -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))); + } + } +} diff --git a/lib/screens/siteConfig/AddCertificateScreen.dart b/lib/screens/siteConfig/AddCertificateScreen.dart index 01cfd56..1360f1a 100644 --- a/lib/screens/siteConfig/AddCertificateScreen.dart +++ b/lib/screens/siteConfig/AddCertificateScreen.dart @@ -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 { 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;