-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add SignInWithPhoneButtonView
- Loading branch information
1 parent
c86fd0c
commit 9b6cace
Showing
7 changed files
with
163 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
Sources/SwiftfulFirebaseAuth/Core/ASAuthorizationAppleIDButton+EXT.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// ASAuthorizationAppleIDButton.swift | ||
// | ||
// | ||
// Created by Nick Sarno on 4/22/24. | ||
// | ||
|
||
import Foundation | ||
import SwiftUI | ||
import AuthenticationServices | ||
|
||
extension ASAuthorizationAppleIDButton.Style { | ||
var backgroundColor: Color { | ||
switch self { | ||
case .white: | ||
return .white | ||
case .whiteOutline: | ||
return .white | ||
default: | ||
return .black | ||
} | ||
} | ||
|
||
var foregroundColor: Color { | ||
switch self { | ||
case .white: | ||
return .black | ||
case .whiteOutline: | ||
return .black | ||
default: | ||
return .white | ||
} | ||
} | ||
|
||
var borderColor: Color { | ||
switch self { | ||
case .white: | ||
return .white | ||
case .whiteOutline: | ||
return .black | ||
default: | ||
return .black | ||
} | ||
} | ||
} | ||
|
||
extension ASAuthorizationAppleIDButton.ButtonType { | ||
var buttonText: String { | ||
switch self { | ||
case .signIn: | ||
return "Sign in with" | ||
case .continue: | ||
return "Continue with" | ||
case .signUp: | ||
return "Sign up with" | ||
default: | ||
return "Sign in with" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
Sources/SwiftfulFirebaseAuth/Core/SignInWithPhoneButtonView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// SignInWithPhoneButtonView.swift | ||
// | ||
// | ||
// Created by Nick Sarno on 4/22/24. | ||
// | ||
|
||
import SwiftUI | ||
import SwiftUI | ||
import AuthenticationServices | ||
|
||
public struct SignInWithPhoneButtonView: View { | ||
|
||
private var backgroundColor: Color | ||
private var foregroundColor: Color | ||
private var borderColor: Color | ||
private var buttonText: String | ||
private var cornerRadius: CGFloat | ||
|
||
public init( | ||
type: ASAuthorizationAppleIDButton.ButtonType = .signIn, | ||
style: ASAuthorizationAppleIDButton.Style = .black, | ||
cornerRadius: CGFloat = 10 | ||
) { | ||
self.cornerRadius = cornerRadius | ||
self.backgroundColor = style.backgroundColor | ||
self.foregroundColor = style.foregroundColor | ||
self.borderColor = style.borderColor | ||
self.buttonText = type.buttonText | ||
} | ||
|
||
public var body: some View { | ||
ZStack { | ||
RoundedRectangle(cornerRadius: cornerRadius) | ||
.fill(borderColor) | ||
|
||
RoundedRectangle(cornerRadius: cornerRadius) | ||
.fill(backgroundColor) | ||
.padding(0.8) | ||
|
||
HStack(spacing: 8) { | ||
Image(systemName: "phone.fill") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 16, height: 16) | ||
|
||
Text("\(buttonText) Phone") | ||
.font(.system(size: 21)) | ||
.fontWeight(.medium) | ||
} | ||
.foregroundColor(foregroundColor) | ||
} | ||
.padding(.vertical, 1) | ||
.disabled(true) | ||
} | ||
} | ||
|
||
#Preview("SignInWithGoogleButtonView") { | ||
VStack { | ||
SignInWithAppleButtonView() | ||
.frame(height: 60) | ||
.padding() | ||
SignInWithGoogleButtonView() | ||
.frame(height: 60) | ||
.padding() | ||
SignInWithPhoneButtonView() | ||
.frame(height: 60) | ||
.padding() | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Sources/SwiftfulFirebaseAuth/Support/Assets.xcassets/GoogleRed.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0x35", | ||
"green" : "0x43", | ||
"red" : "0xEA" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |