From 71e0105a29139b7a49c7119f08cd9183fe5ba92e Mon Sep 17 00:00:00 2001 From: nilsreichardt Date: Tue, 8 Aug 2023 22:56:17 +0200 Subject: [PATCH] Use custom Sign In With Apple button --- app/assets/logo/apple-logo.svg | 77 +++++++++++++++ app/lib/auth/login_page.dart | 16 +-- app/lib/widgets/apple_sign_in_button.dart | 113 ---------------------- 3 files changed, 85 insertions(+), 121 deletions(-) create mode 100644 app/assets/logo/apple-logo.svg delete mode 100644 app/lib/widgets/apple_sign_in_button.dart diff --git a/app/assets/logo/apple-logo.svg b/app/assets/logo/apple-logo.svg new file mode 100644 index 000000000..af1f2c676 --- /dev/null +++ b/app/assets/logo/apple-logo.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/lib/auth/login_page.dart b/app/lib/auth/login_page.dart index c246edb04..b9f75175e 100644 --- a/app/lib/auth/login_page.dart +++ b/app/lib/auth/login_page.dart @@ -19,7 +19,6 @@ import 'package:sharezone/download_app_tip/widgets/download_app_tip_card.dart'; import 'package:sharezone/groups/src/widgets/contact_support.dart'; import 'package:sharezone/onboarding/sign_up/sign_up_page.dart'; import 'package:sharezone/util/flavor.dart'; -import 'package:sharezone/widgets/apple_sign_in_button.dart'; import 'package:sharezone_common/api_errors.dart'; import 'package:sharezone_widgets/sharezone_widgets.dart'; @@ -540,14 +539,15 @@ class _LoginWithAppleButton extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.fromLTRB(6, 32, 12, 0), - child: SignInWithAppleButton( - onPressed: onLogin, - text: 'Mit Apple anmelden', - height: 45, - iconAlignment: IconAlignment.left, + return _SignWithOAuthButton( + icon: PlatformSvg.asset( + "assets/logo/apple-logo.svg", + width: 24, + height: 24, + color: isDarkThemeEnabled(context) ? Colors.white : Colors.black, ), + onTap: onLogin, + text: 'Über Apple anmelden', ); } } diff --git a/app/lib/widgets/apple_sign_in_button.dart b/app/lib/widgets/apple_sign_in_button.dart deleted file mode 100644 index 923d4fdc1..000000000 --- a/app/lib/widgets/apple_sign_in_button.dart +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) -// Licensed under the EUPL-1.2-or-later. -// -// You may obtain a copy of the Licence at: -// https://joinup.ec.europa.eu/software/page/eupl -// -// SPDX-License-Identifier: EUPL-1.2 - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -/// Style according to -/// https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/buttons/ -class SignInWithAppleButton extends StatelessWidget { - const SignInWithAppleButton({ - Key key, - @required this.onPressed, - this.text = 'Sign in with Apple', - this.height = 44, - this.style = SignInWithAppleButtonStyle.dark, - this.borderRadius = const BorderRadius.all(Radius.circular(8.0)), - this.iconAlignment = IconAlignment.center, - }) : assert(text != null), - assert(height != null), - assert(style != null), - assert(borderRadius != null), - assert(iconAlignment != null), - super(key: key); - - final VoidCallback onPressed; - - final String text; - - final double height; - - final SignInWithAppleButtonStyle style; - - final BorderRadius borderRadius; - - final IconAlignment iconAlignment; - - @override - Widget build(BuildContext context) { - final backgroundColor = - style == SignInWithAppleButtonStyle.dark ? Colors.black : Colors.white; - final contrastColor = - style == SignInWithAppleButtonStyle.dark ? Colors.white : Colors.black; - - return Container( - height: height, - child: SizedBox.expand( - child: CupertinoButton( - borderRadius: borderRadius, - padding: EdgeInsets.zero, - color: backgroundColor, - child: Container( - decoration: style == SignInWithAppleButtonStyle.white - ? BoxDecoration( - border: Border.all(width: 1, color: Colors.black), - borderRadius: borderRadius, - ) - : null, - padding: EdgeInsets.symmetric( - horizontal: 16.0, - ), - height: height, - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 4), - child: Icon( - FontAwesomeIcons.apple, - size: 26, - color: Colors.white, - ), - ), - Padding( - padding: EdgeInsets.only( - left: iconAlignment == IconAlignment.left ? 16 : 0), - child: Text( - text, - style: TextStyle( - fontSize: height * 0.43 /* per Apple's guidelines */, - color: contrastColor, - ), - ), - ), - if (iconAlignment == IconAlignment.left) - // so text gets center aligned - Container(width: 0), - ], - mainAxisAlignment: iconAlignment == IconAlignment.left - ? MainAxisAlignment.spaceBetween - : MainAxisAlignment.center, - ), - ), - onPressed: onPressed, - ), - ), - ); - } -} - -enum SignInWithAppleButtonStyle { - dark, - white, -} - -enum IconAlignment { - center, - left, -}