Skip to content

Commit 6d26ad6

Browse files
authored
Merge pull request #1 from sugijotaro/develop
2 parents 657c119 + 249664e commit 6d26ad6

29 files changed

+1519
-174
lines changed

README.ja.md

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Xcodeの場合:
4040
4. Xcodeのプロジェクト設定で「Sign in with Apple」のCapabilityを追加
4141
5. Google認証を利用する場合は、Google Cloud ConsoleでOAuthクライアントIDを取得し、Firebaseプロジェクトに設定
4242

43+
より詳しいセットアップ手順は[こちらの記事](https://qiita.com/sugijotaro/items/35daf9f6eba4d88c7bd2)をご覧ください
44+
4345
## 基本的な使い方
4446
```swift
4547
import SwiftUI
@@ -52,16 +54,24 @@ struct ContentView: View {
5254
}
5355
```
5456

57+
## デモアプリ
58+
59+
[`sample/FirebaseAuthEasierDemoApp`](sample/FirebaseAuthEasierDemoApp) ディレクトリにデモアプリがあります。
60+
61+
FirebaseAuthEasierの動作例や導入の参考としてご利用いただけます。
62+
5563
## FirebaseAuthViewのカスタマイズ
5664
`FirebaseAuthView`は、以下のイニシャライザ引数で柔軟にカスタマイズできます。
5765

5866
```swift
5967
public init(
6068
providers: [SignInProviderType]? = nil,
6169
labelType: SignInButtonLabelType = .signIn,
62-
@ViewBuilder content: @escaping () -> Content = { FirebaseAuthDefaultContentView() },
70+
termsOfServiceURL: URL? = nil,
71+
privacyPolicyURL: URL? = nil,
6372
onSignInStart: ((SignInProviderType) -> Void)? = nil,
64-
didSignIn: ((Result<AuthDataResult, Error>) -> Void)? = nil
73+
didSignIn: ((Result<AuthDataResult, Error>) -> Void)? = nil,
74+
@ViewBuilder content: @escaping () -> Content = { FirebaseAuthDefaultContentView() }
6575
)
6676
```
6777

@@ -79,6 +89,18 @@ FirebaseAuthView(providers: [.apple]) // Appleサインインのみ
7989
FirebaseAuthView(labelType: .signUp)
8090
```
8191

92+
#### termsOfServiceURL(デフォルト: nil)
93+
利用規約のURL。指定すると、サインイン画面下部にメッセージが表示されます。
94+
```swift
95+
FirebaseAuthView(termsOfServiceURL: URL(string: "https://example.com/terms"))
96+
```
97+
98+
#### privacyPolicyURL(デフォルト: nil)
99+
プライバシーポリシーのURL。指定すると、サインイン画面下部にメッセージが表示されます。
100+
```swift
101+
FirebaseAuthView(privacyPolicyURL: URL(string: "https://example.com/privacy"))
102+
```
103+
82104
#### content(デフォルト: FirebaseAuthDefaultContentView)
83105
サインイン画面上部に表示する任意のViewをカスタマイズできます。
84106
```swift
@@ -113,19 +135,32 @@ FirebaseAuthView(didSignIn: { result in
113135

114136
### 組み合わせ例
115137
```swift
116-
FirebaseAuthView(
117-
providers: [.apple, .google],
118-
labelType: .continue,
119-
onSignInStart: { provider in
120-
// ローディング表示やログ出力など
121-
},
122-
didSignIn: { result in
123-
// サインイン完了時の処理
124-
}
125-
) {
126-
VStack {
127-
Text("アプリへようこそ!")
128-
// 任意のカスタムView
138+
struct ContentView: View {
139+
var body: some View {
140+
FirebaseAuthView(
141+
providers: [.apple, .google],
142+
labelType: .continue,
143+
termsOfServiceURL: URL(string: "https://example.com/terms")!,
144+
privacyPolicyURL: URL(string: "https://example.com/privacy")!,
145+
onSignInStart: { provider in
146+
print("Sign-in started with provider: \(provider)")
147+
},
148+
didSignIn: { result in
149+
switch result {
150+
case .success(let authResult):
151+
print("Sign-in successful")
152+
case .failure(let error):
153+
print("Sign-in failed: \(error.localizedDescription)")
154+
}
155+
}
156+
) {
157+
VStack {
158+
Image(systemName: "person.circle")
159+
.imageScale(.large)
160+
.foregroundStyle(.tint)
161+
Text("ようこそ!")
162+
}
163+
}
129164
}
130165
}
131166
```
@@ -153,8 +188,8 @@ authService.signOut { result in /* ... */ }
153188
`SignInButton`はApple/Google用のサインインボタンUIを個別に利用でき、色・ラベル・角丸・枠線など細かくカスタマイズ可能です。
154189

155190
```swift
156-
import FirebaseAuthEasier
157191
import SwiftUI
192+
import FirebaseAuthEasier
158193

159194
SignInButton(
160195
provider: .apple,

README.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# FirebaseAuthEasier
22

3+
[日本語READMEはこちら](./README.ja.md)
4+
35
[![Swift Package Manager Compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
46
[![Platform](https://img.shields.io/badge/Platform-iOS%2015.0%2B-blue.svg)](https://developer.apple.com/ios/)
57
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
@@ -40,6 +42,8 @@ In Xcode:
4042
4. **Add "Sign in with Apple" capability in Xcode project settings**
4143
5. For Google authentication, obtain OAuth client ID from Google Cloud Console and configure it in your Firebase project
4244

45+
For more detailed setup instructions, see [this article (Japanese only)](https://qiita.com/sugijotaro/items/35daf9f6eba4d88c7bd2)
46+
4347
## Basic Usage
4448
```swift
4549
import SwiftUI
@@ -52,16 +56,24 @@ struct ContentView: View {
5256
}
5357
```
5458

59+
## Demo App
60+
61+
A demo app is available in the [`sample/FirebaseAuthEasierDemoApp`](sample/FirebaseAuthEasierDemoApp) directory.
62+
63+
You can use this app to see FirebaseAuthEasier in action and as a reference for integration.
64+
5565
## FirebaseAuthView Customization
5666
`FirebaseAuthView` can be flexibly customized with the following initializer parameters:
5767

5868
```swift
5969
public init(
6070
providers: [SignInProviderType]? = nil,
6171
labelType: SignInButtonLabelType = .signIn,
62-
@ViewBuilder content: @escaping () -> Content = { FirebaseAuthDefaultContentView() },
72+
termsOfServiceURL: URL? = nil,
73+
privacyPolicyURL: URL? = nil,
6374
onSignInStart: ((SignInProviderType) -> Void)? = nil,
64-
didSignIn: ((Result<AuthDataResult, Error>) -> Void)? = nil
75+
didSignIn: ((Result<AuthDataResult, Error>) -> Void)? = nil,
76+
@ViewBuilder content: @escaping () -> Content = { FirebaseAuthDefaultContentView() }
6577
)
6678
```
6779

@@ -79,6 +91,18 @@ Specify the button label type (.signIn, .signUp, .continue).
7991
FirebaseAuthView(labelType: .signUp)
8092
```
8193

94+
#### termsOfServiceURL (Default: nil)
95+
URL for Terms of Service. If provided, a legal message will be displayed at the bottom of the sign-in screen.
96+
```swift
97+
FirebaseAuthView(termsOfServiceURL: URL(string: "https://example.com/terms"))
98+
```
99+
100+
#### privacyPolicyURL (Default: nil)
101+
URL for Privacy Policy. If provided, a legal message will be displayed at the bottom of the sign-in screen.
102+
```swift
103+
FirebaseAuthView(privacyPolicyURL: URL(string: "https://example.com/privacy"))
104+
```
105+
82106
#### content (Default: FirebaseAuthDefaultContentView)
83107
Customize the view displayed at the top of the sign-in screen.
84108
```swift
@@ -113,19 +137,32 @@ FirebaseAuthView(didSignIn: { result in
113137

114138
### Combined Example
115139
```swift
116-
FirebaseAuthView(
117-
providers: [.apple, .google],
118-
labelType: .continue,
119-
onSignInStart: { provider in
120-
// Show loading indicator or log output
121-
},
122-
didSignIn: { result in
123-
// Handle sign-in completion
124-
}
125-
) {
126-
VStack {
127-
Text("Welcome to our app!")
128-
// Any custom view
140+
struct ContentView: View {
141+
var body: some View {
142+
FirebaseAuthView(
143+
providers: [.apple, .google],
144+
labelType: .continue,
145+
termsOfServiceURL: URL(string: "https://example.com/terms")!,
146+
privacyPolicyURL: URL(string: "https://example.com/privacy")!,
147+
onSignInStart: { provider in
148+
print("Sign-in started with provider: \(provider)")
149+
},
150+
didSignIn: { result in
151+
switch result {
152+
case .success(let authResult):
153+
print("Sign-in successful")
154+
case .failure(let error):
155+
print("Sign-in failed: \(error.localizedDescription)")
156+
}
157+
}
158+
) {
159+
VStack {
160+
Image(systemName: "person.circle")
161+
.imageScale(.large)
162+
.foregroundStyle(.tint)
163+
Text("Welcome!")
164+
}
165+
}
129166
}
130167
}
131168
```
@@ -153,8 +190,8 @@ authService.signOut { result in /* ... */ }
153190
`SignInButton` provides Apple/Google sign-in button UI that can be used individually, with fine-grained customization for colors, labels, corner radius, borders, and more.
154191

155192
```swift
156-
import FirebaseAuthEasier
157193
import SwiftUI
194+
import FirebaseAuthEasier
158195

159196
SignInButton(
160197
provider: .apple,

Sources/FirebaseAuthEasier/Resources/Localizable.xcstrings

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@
413413
}
414414
},
415415
"Continue with Apple" : {
416+
"extractionState" : "manual",
416417
"localizations" : {
417418
"cs" : {
418419
"stringUnit" : {
@@ -549,6 +550,7 @@
549550
}
550551
},
551552
"Continue with Google" : {
553+
"extractionState" : "manual",
552554
"localizations" : {
553555
"cs" : {
554556
"stringUnit" : {
@@ -1094,6 +1096,7 @@
10941096
}
10951097
},
10961098
"Sign in with Google" : {
1099+
"extractionState" : "manual",
10971100
"localizations" : {
10981101
"cs" : {
10991102
"stringUnit" : {
@@ -1230,6 +1233,7 @@
12301233
}
12311234
},
12321235
"Sign up with Apple" : {
1236+
"extractionState" : "manual",
12331237
"localizations" : {
12341238
"cs" : {
12351239
"stringUnit" : {
@@ -1366,6 +1370,7 @@
13661370
}
13671371
},
13681372
"Sign up with Google" : {
1373+
"extractionState" : "manual",
13691374
"localizations" : {
13701375
"cs" : {
13711376
"stringUnit" : {
@@ -1502,7 +1507,6 @@
15021507
}
15031508
},
15041509
"Signing in..." : {
1505-
"extractionState" : "manual",
15061510
"localizations" : {
15071511
"cs" : {
15081512
"stringUnit" : {

Sources/FirebaseAuthEasier/View/FirebaseAuthDefaultContentView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ public struct FirebaseAuthDefaultContentView: View {
2626
Text(appName)
2727
.font(.largeTitle)
2828
.bold()
29+
.lineLimit(1)
30+
.minimumScaleFactor(0.5)
2931
}
3032
}
3133
.frame(maxWidth: .infinity)
3234
.padding(.vertical, 32)
35+
.padding(.horizontal)
3336
}
3437
}
3538

Sources/FirebaseAuthEasier/View/FirebaseAuthView.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ public struct FirebaseAuthView<Content: View>: View {
1616
public init(
1717
providers: [SignInProviderType]? = nil,
1818
labelType: SignInButtonLabelType = .signIn,
19-
@ViewBuilder content: @escaping () -> Content = { FirebaseAuthDefaultContentView() },
19+
termsOfServiceURL: URL? = nil,
20+
privacyPolicyURL: URL? = nil,
2021
onSignInStart: ((SignInProviderType) -> Void)? = nil,
21-
didSignIn: ((Result<AuthDataResult, Error>) -> Void)? = nil
22+
didSignIn: ((Result<AuthDataResult, Error>) -> Void)? = nil,
23+
@ViewBuilder content: @escaping () -> Content = { FirebaseAuthDefaultContentView() }
2224
) {
2325
_viewModel = StateObject(wrappedValue: FirebaseAuthViewModel(
2426
providers: providers,
2527
labelType: labelType,
28+
termsOfServiceURL: termsOfServiceURL,
29+
privacyPolicyURL: privacyPolicyURL,
2630
onSignInStart: onSignInStart,
2731
didSignIn: { result in
2832
didSignIn?(result)
@@ -33,14 +37,7 @@ public struct FirebaseAuthView<Content: View>: View {
3337

3438
public var body: some View {
3539
FirebaseAuthViewComponent(
36-
providers: viewModel.providers,
37-
isSigningIn: viewModel.isSigningIn,
38-
labelType: viewModel.labelType,
39-
onSignInStart: viewModel.onSignInStart,
40-
handleSignIn: { provider in
41-
viewModel.handleSignIn(provider: provider)
42-
},
43-
signInResult: signInResult,
40+
viewModel: viewModel,
4441
content: content
4542
)
4643
.onChange(of: viewModel.isSigningIn) { isSigningIn in

0 commit comments

Comments
 (0)