-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
157 changed files
with
7,193 additions
and
3,859 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
11 changes: 11 additions & 0 deletions
11
Examples/Authenticator/Authenticator/Assets.xcassets/AccentColor.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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
Examples/Authenticator/Authenticator/Assets.xcassets/AppIcon.appiconset/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,122 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "83.5x83.5" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "ios-marketing", | ||
"scale" : "1x", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+536 Bytes
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.05 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.85 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+732 Bytes
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.9 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.64 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.05 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.31 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.28 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.28 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+13.8 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.8 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.88 KB
...nticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.5 KB
...ator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+648 KB
...enticator/Authenticator/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
Examples/Authenticator/Authenticator/Assets.xcassets/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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Examples/Authenticator/Authenticator/Assets.xcassets/header.imageset/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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "header.png", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+32.2 KB
Examples/Authenticator/Authenticator/Assets.xcassets/header.imageset/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions
17
Examples/Authenticator/Authenticator/AuthenticatorApp.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,17 @@ | ||
// | ||
// AuthenticatorApp.swift | ||
// Authenticator | ||
// | ||
// Created by Stefano Bertagno on 07/02/21. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@main | ||
struct AuthenticatorApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView().accentColor(.pink) | ||
} | ||
} | ||
} |
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,66 @@ | ||
// | ||
// ContentView.swift | ||
// Authenticator | ||
// | ||
// Created by Stefano Bertagno on 07/02/21. | ||
// | ||
|
||
import SwiftUI | ||
|
||
import Swiftagram | ||
|
||
struct ContentView: View { | ||
/// Whether it should present the login view or not. | ||
@State var isPresentingLoginView: Bool = false | ||
/// The current secret. | ||
@State var secret: Secret? | ||
|
||
/// The actual view. | ||
var body: some View { | ||
VStack(spacing: 40) { | ||
// The header. | ||
Image("header") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(maxWidth: .infinity) | ||
.padding(.horizontal, 50) | ||
// Check for token. | ||
if let secret = secret, let token = secret.token { | ||
Text(token) | ||
.font(Font.headline.smallCaps()) | ||
.foregroundColor(.primary) | ||
.lineLimit(3) | ||
.fixedSize(horizontal: false, vertical: true) | ||
.onTapGesture { UIPasteboard.general.string = token } | ||
Text("(Tap to copy it in your clipboard)") | ||
.font(.caption) | ||
.fixedSize(horizontal: false, vertical: true) | ||
} else { | ||
// The disclaimer. | ||
Text.combine( | ||
Text("Please authenticate with your "), | ||
Text("Instagram").bold(), | ||
Text(" account to receive a token for "), | ||
Text("SwiftagramTests").bold() | ||
) | ||
.fixedSize(horizontal: false, vertical: true) | ||
// Login. | ||
Button(action: { isPresentingLoginView = true }) { | ||
Text("Authenticate").font(.headline) | ||
}.foregroundColor(.accentColor) | ||
} | ||
} | ||
.foregroundColor(.secondary) | ||
.multilineTextAlignment(.center) | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.padding(.vertical) | ||
.padding(.horizontal, 50) | ||
.sheet(isPresented: $isPresentingLoginView) { LoginView(secret: $secret) } | ||
} | ||
} | ||
|
||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContentView() | ||
} | ||
} |
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,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UIApplicationSceneManifest</key> | ||
<dict> | ||
<key>UIApplicationSupportsMultipleScenes</key> | ||
<true/> | ||
</dict> | ||
<key>UIApplicationSupportsIndirectInputEvents</key> | ||
<true/> | ||
<key>UILaunchScreen</key> | ||
<dict/> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations~ipad</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</plist> |
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,58 @@ | ||
// | ||
// LoginView.swift | ||
// Authenticator | ||
// | ||
// Created by Stefano Bertagno on 07/02/21. | ||
// | ||
|
||
import SwiftUI | ||
import UIKit | ||
import WebKit | ||
|
||
import Swiftagram | ||
|
||
/// A `class` defining a view controller capable of displaying the authentication web view. | ||
class LoginViewController: UIViewController { | ||
/// The completion handler. | ||
var completion: ((Secret) -> Void)? { | ||
didSet { | ||
guard oldValue == nil, let completion = completion else { return } | ||
// Authenticate. | ||
DispatchQueue.main.asyncAfter(deadline: .now()) { | ||
Authenticator.transient | ||
.visual(filling: self.view) | ||
.authenticate() | ||
.sink(receiveCompletion: { _ in self.dismiss(animated: true, completion: nil) }, | ||
receiveValue: completion) | ||
.store(in: &self.bin) | ||
} | ||
} | ||
} | ||
|
||
/// The dispose bag. | ||
private var bin: Set<AnyCancellable> = [] | ||
} | ||
|
||
/// A `struct` defining a `View` used for logging in. | ||
struct LoginView: UIViewControllerRepresentable { | ||
/// A `Secret` binding. | ||
@Binding var secret: Secret? | ||
|
||
/// Compose the actual controller. | ||
/// | ||
/// - parameter context: A valid `Context`. | ||
/// - returns: A valid `LoginViewController`. | ||
func makeUIViewController(context: Context) -> LoginViewController { | ||
let controller = LoginViewController() | ||
controller.completion = { secret = $0 } | ||
return controller | ||
} | ||
|
||
/// Update the controller. | ||
/// | ||
/// - parameters: | ||
/// - uiViewController: A valid `LoginViewController`. | ||
/// - context: A valid `Context`. | ||
func updateUIViewController(_ uiViewController: LoginViewController, context: Context) { | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Examples/Authenticator/Authenticator/Preview Content/Preview Assets.xcassets/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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,15 @@ | ||
// | ||
// Secret.swift | ||
// Authenticator | ||
// | ||
// Created by Stefano Bertagno on 07/02/21. | ||
// | ||
|
||
import Foundation | ||
|
||
import Swiftagram | ||
|
||
extension Secret { | ||
/// Compute the token. | ||
var token: String? { try? JSONEncoder().encode(self).base64EncodedString() } | ||
} |
Oops, something went wrong.