Skip to content

Commit

Permalink
getting caught up with signup process
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkQween committed Jun 5, 2024
1 parent 9efebc8 commit d8c4eee
Show file tree
Hide file tree
Showing 168 changed files with 1,705 additions and 6,416 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,7 @@ render.experimental.xml
google-services.json

# Android Profiling
*.hprof
*.hprof

db.json
admin.json
Binary file added bun.lockb
Binary file not shown.
Binary file modified client/.DS_Store
Binary file not shown.
Binary file modified client/iOS/.DS_Store
Binary file not shown.
145 changes: 136 additions & 9 deletions client/iOS/SoulSync.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
ReferencedContainer = "container:SoulSync.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "954B5F932C0D0E690022F859"
BuildableName = "SoulSyncUITests.xctest"
BlueprintName = "SoulSyncUITests"
ReferencedContainer = "container:SoulSync.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
3 changes: 2 additions & 1 deletion client/iOS/SoulSync/Constants/NetworkInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

import Foundation

let apiURL: URL = URL(string: "https://soulsync.hannaskairipa.com/api")!
let apiURL: String = "https://soulsync.hannaskairipa.com/api/private"
let testingApiURL: String = "https://soulsync.hannaskairipa.com/api/private/tests"
6 changes: 3 additions & 3 deletions client/iOS/SoulSync/Data/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Androgyne", "Femme", "Butch", "Two-Gender", "Genderqueer", "Multigender", "Omnigender", "Xenogender",
"Aporagender", "Librafluid", "Subgender", "Epigender", "Proxvir", "Surgender", "Fluidflux", "Vapogender",
"Faunagender", "Astralgender", "Autigender", "Colorgender", "Exgender", "Caelgender", "Gendervex",
"Elyragender", "Enby", "Juxera", "Ambonec", "Aesthetigender"
"Elyragender", "Enby", "Juxera", "Ambonec", "Aesthetigender", "Other"
],
"multiple": false
},
Expand Down Expand Up @@ -74,7 +74,7 @@
},
"sexualityOptions": {
"options": [
"Straight", "Gay", "Lesbian", "Bisexual", "Pansexual", "Queer", "Asexual", "Demisexual", "Graysexual",
"Straight", "Gay (MTM)", "Lesbian", "Bisexual", "Pansexual", "Queer", "Asexual", "Demisexual", "Graysexual",
"Homoflexible", "Heteroflexible", "Androsexual", "Gynosexual", "Skoliosexual", "Polysexual", "Omnicomsexual",
"Questioning", "Other"
],
Expand All @@ -89,7 +89,7 @@
"multiple": false
},
"ageRange": {
"options": ["±0", "±1", "±2", "±4", "±8", "±16", "±32", "±64", "No Limit"],
"options": ["±0", "±1", "±2", "±4", "±8", "±16", "±32", "±64", "No Limit", "Custom"],
"multiple": false
}
}
52 changes: 38 additions & 14 deletions client/iOS/SoulSync/Networking/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,45 @@ class NetworkManager {
task.resume()
}

func post(to url: URL, with parameters: [String: Any], completion: @escaping (Data?, URLResponse?, Error?) -> Void) {
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

do {
request.httpBody = try JSONSerialization.data(withJSONObject: parameters)
} catch {
completion(nil, nil, error)
return
}

let task = session.dataTask(with: request, completionHandler: completion)
task.resume()
func post(to url: URL, body parameters: [String: Any] = [:], headers: [String: String] = [:], completion: @escaping (Data?, URLResponse?, Error?) -> Void) {
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

do {
request.httpBody = try JSONSerialization.data(withJSONObject: parameters)
} catch {
completion(nil, nil, error)
return
}

for (key, value) in headers {
request.addValue(value, forHTTPHeaderField: key)
}

let task = session.dataTask(with: request, completionHandler: completion)
task.resume()
}

func put(to url: URL, body parameters: [String: Any], headers: [String: String], completion: @escaping (Data?, URLResponse?, Error?) -> Void) {
var request = URLRequest(url: url)
request.httpMethod = "PUT"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

do {
request.httpBody = try JSONSerialization.data(withJSONObject: parameters)
} catch {
completion(nil, nil, error)
return
}

for (key, value) in headers {
request.addValue(value, forHTTPHeaderField: key)
}

let task = session.dataTask(with: request, completionHandler: completion)
task.resume()
}

func delete(to url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> Void) {
var request = URLRequest(url: url)
Expand Down
10 changes: 9 additions & 1 deletion client/iOS/SoulSync/Networking/ServerErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@
// Created by Hanna Skairipa on 6/4/24.
//

import Foundation
enum ServerErrors: String {
case WRONG_CODE = "WRONG_CODE"
case PASSWORD_MISMATCH = "PASSWORD_MISMATCH"
case USER_NOT_FOUND = "USER_NOT_FOUND"
case WRONG_PASSWORD = "WRONG_PASSWORD"
case EMAIL_EXISTS = "EMAIL_EXISTS"
case NO_TOKEN = "NO_TOKEN"
case INVALID_TOKEN = "INVALID_TOKEN"
}
2 changes: 2 additions & 0 deletions client/iOS/SoulSync/SoulSync.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.siri</key>
<true/>
<key>com.apple.developer.usernotifications.time-sensitive</key>
<true/>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion client/iOS/SoulSync/SoulSyncApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct SoulSyncApp: App {

var body: some Scene {
WindowGroup {
PitchCreatorView()
FirstLaunchView()
.preferredColorScheme(.dark)
}
}
Expand Down
56 changes: 56 additions & 0 deletions client/iOS/SoulSync/Utils/KeychainManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,60 @@
// Created by Hanna Skairipa on 6/4/24.
//

import Security
import Foundation

class KeychainManager {
class func save(key: String, data: Data) -> OSStatus {
let query = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key,
kSecValueData as String: data
] as [String : Any]

SecItemDelete(query as CFDictionary)

return SecItemAdd(query as CFDictionary, nil)
}

class func loadData(key: String) -> Data? {
let query = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key,
kSecReturnData as String: kCFBooleanTrue!,
kSecMatchLimit as String: kSecMatchLimitOne
] as [String : Any]

var dataTypeRef: AnyObject? = nil
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &dataTypeRef)

if status == noErr {
return dataTypeRef as! Data?
} else {
return nil
}
}

class func delete(key: String) -> OSStatus {
let query = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: key
] as [String : Any]

return SecItemDelete(query as CFDictionary)
}

class func save(key: String, value: String) -> OSStatus {
if let data = value.data(using: .utf8) {
return save(key: key, data: data)
}
return errSecParam
}

class func loadString(key: String) -> String {
if let data = loadData(key: key) {
return String(data: data, encoding: .utf8) ?? ""
}
return ""
}
}
60 changes: 53 additions & 7 deletions client/iOS/SoulSync/Utils/VideoStreamingManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,60 @@
// Created by Hanna Skairipa on 6/5/24.
//

import SwiftUI
import AVKit

struct VideoStreamingManager: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
class VideoPlayerManager: ObservableObject {
private var player: AVPlayer?
private var playerItem: AVPlayerItem?
private var playerLayer: AVPlayerLayer?
public var isPlaying: Bool = false
public var userEmail: String = ""

init(url: URL, authorizationToken: String) {
let headers = ["Authorization": "Bearer \(authorizationToken)"]
let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])
self.playerItem = AVPlayerItem(asset: asset)
self.player = AVPlayer(playerItem: playerItem)
extractEmail(from: url, authorizationToken: authorizationToken)
}
}

#Preview {
VideoStreamingManager()
func play() {
player?.play()
self.isPlaying.toggle()
}

func pause() {
player?.pause()
self.isPlaying.toggle()
}

func getPlayerLayer() -> AVPlayerLayer? {
if playerLayer == nil {
playerLayer = AVPlayerLayer(player: player)
}
return playerLayer
}

private func extractEmail(from url: URL, authorizationToken: String) {
var request = URLRequest(url: url)
request.setValue("Bearer \(authorizationToken)", forHTTPHeaderField: "Authorization")
request.httpMethod = "HEAD" // Only request headers

URLSession.shared.dataTask(with: request) { [weak self] (_, response, error) in
guard let httpResponse = response as? HTTPURLResponse, error == nil else {
print("Failed to get headers: \(error?.localizedDescription ?? "Unknown error")")
return
}

if let email = httpResponse.allHeaderFields["user"] as? String {
DispatchQueue.main.async {
self?.userEmail = email
}
}

dump(httpResponse)
print("Internal print")
print(self?.userEmail ?? "")
}.resume()
}
}
11 changes: 6 additions & 5 deletions client/iOS/SoulSync/Views/Startup/FirstLaunch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ struct OnboardingProcess: View {
@State private var isLoginSuccessful = false
@Binding var signUp: Bool
@State private var isCompleteSignUp = false
@State private var phone = ""
// @State private var phone = ""
@State private var email = ""
@State private var token = ""
@State private var addedDetails = false
@State private var addedPreferences = false
Expand Down Expand Up @@ -121,13 +122,13 @@ struct OnboardingProcess: View {
@ViewBuilder
private var signUpView: some View {
if !isSignUpSuccessful {
SignUpInfoView(isSignUpSuccessful: $isSignUpSuccessful, fullPhoneNumber: $phone, token: $token)
SignUpInfoView(isSignUpSuccessful: $isSignUpSuccessful, email: $email, token: $token)
} else if !isCompleteSignUp {
PhoneVerificationView(isCompleteSignUp: $isCompleteSignUp, phoneNumber: $phone, token: $token)
PhoneVerificationView(isCompleteSignUp: $isCompleteSignUp, email: $email, token: $token)
} else if !addedDetails {
DescriptorsView(addedDetails: $addedDetails, phoneNumber: $phone)
DescriptorsView(addedDetails: $addedDetails, email: $email)
} else if !addedPreferences {
PreferencesView(addedPreferences: $addedPreferences, phoneNumber: $phone)
PreferencesView(addedPreferences: $addedPreferences, email: $email)
} else {
RewelcomeView()
}
Expand Down
Loading

0 comments on commit d8c4eee

Please sign in to comment.