-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce PersonNameComponents for GoogleSignIn
- Loading branch information
1 parent
cb1cfb4
commit b4186af
Showing
4 changed files
with
54 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// PersonNameComponents+Extension.swift | ||
// PovioKitAuth | ||
// | ||
// Created by Egzon Arifi on 09/11/2024. | ||
// | ||
|
||
import AuthenticationServices | ||
import Foundation | ||
|
||
public extension PersonNameComponents { | ||
var name: String? { | ||
guard let givenName = givenName else { | ||
return familyName | ||
} | ||
guard let familyName = familyName else { | ||
return givenName | ||
} | ||
return "\(givenName) \(familyName)" | ||
} | ||
} | ||
|
||
public extension PersonNameComponents { | ||
static func create(namePrefix: String? = .none, | ||
middleName: String? = .none, | ||
givenName: String? = .none, | ||
familyName: String? = .none, | ||
nameSuffix: String? = .none, | ||
nickname: String? = .none, | ||
phoneticRepresentation: PersonNameComponents? = .none) -> PersonNameComponents { | ||
var components = PersonNameComponents() | ||
components.namePrefix = namePrefix | ||
components.familyName = familyName | ||
components.middleName = middleName | ||
components.givenName = givenName | ||
components.nameSuffix = nameSuffix | ||
components.nickname = nickname | ||
components.phoneticRepresentation = phoneticRepresentation | ||
return components | ||
} | ||
} |
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