Skip to content

Commit

Permalink
Merge development into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sbertix committed May 6, 2021
2 parents 212e141 + 1b8f701 commit 0f356cf
Show file tree
Hide file tree
Showing 157 changed files with 7,193 additions and 3,859 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ jobs:
- name: Test
env:
SECRET: ${{ secrets.SECRET }}
IV: ${{ secrets.IV }}
KEY: ${{ secrets.KEY }}
PASSWORD: ${{ secrets.PASSWORD }}
run: swift test --parallel --enable-test-discovery --enable-code-coverage
# merge into `main`.
- name: Merge
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ jobs:
- name: Test
env:
SECRET: ${{ secrets.SECRET }}
IV: ${{ secrets.IV }}
KEY: ${{ secrets.KEY }}
PASSWORD: ${{ secrets.PASSWORD }}
run: swift test --parallel --enable-test-discovery
# notify success with a reaction.
- name: Reply (Success)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
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
}
}
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 Examples/Authenticator/Authenticator/AuthenticatorApp.swift
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)
}
}
}
66 changes: 66 additions & 0 deletions Examples/Authenticator/Authenticator/ContentView.swift
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()
}
}
50 changes: 50 additions & 0 deletions Examples/Authenticator/Authenticator/Info.plist
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>
58 changes: 58 additions & 0 deletions Examples/Authenticator/Authenticator/LoginView.swift
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) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
15 changes: 15 additions & 0 deletions Examples/Authenticator/Authenticator/Secret.swift
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() }
}
Loading

0 comments on commit 0f356cf

Please sign in to comment.