Skip to content

Commit

Permalink
Reorganize extensions and views
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentTreguier committed Nov 12, 2024
1 parent 296b651 commit 284b9ba
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 88 deletions.
48 changes: 16 additions & 32 deletions Fyreplace.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ extension CGFloat {
static var logoSize: Self { 80 }
#endif
}

extension String {
static var randomUuid: String {
UUID().uuidString
}
}
File renamed without changes.
7 changes: 0 additions & 7 deletions Fyreplace/Extensions/Label+Destination.swift

This file was deleted.

13 changes: 0 additions & 13 deletions Fyreplace/Extensions/NSTextContentType.swift

This file was deleted.

File renamed without changes.
7 changes: 0 additions & 7 deletions Fyreplace/Extensions/String.swift

This file was deleted.

36 changes: 36 additions & 0 deletions Fyreplace/Extensions/SwiftUI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import SwiftUI

#if os(macOS)
extension NSTextContentType {
static var email: NSTextContentType? {
if #available(macOS 14.0, *) {
.emailAddress
} else {
nil
}
}
}
#else
extension UITextContentType {
static var email: UITextContentType? {
.emailAddress
}
}
#endif

extension View {
func onDeepLink(perform action: @escaping (URL) -> Void) -> some View {
return onOpenURL(perform: action)
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) {
if let url = $0.webpageURL {
action(url)
}
}
}
}

extension Label where Title == Text, Icon == Image {
init(_ destination: Destination) {
self.init(destination.titleKey, systemImage: destination.icon)
}
}
9 changes: 0 additions & 9 deletions Fyreplace/Extensions/UITextContentType.swift

This file was deleted.

12 changes: 0 additions & 12 deletions Fyreplace/Extensions/View.swift

This file was deleted.

2 changes: 0 additions & 2 deletions Fyreplace/Views/Screens/LoginScreenProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@MainActor
protocol LoginScreenProtocol: LoadingViewProtocol {
var api: APIProtocol { get }

var identifier: String { get nonmutating set }
var randomCode: String { get nonmutating set }
var isWaitingForRandomCode: Bool { get nonmutating set }
Expand Down
2 changes: 0 additions & 2 deletions Fyreplace/Views/Screens/RegisterScreenProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@MainActor
protocol RegisterScreenProtocol: LoadingViewProtocol {
var api: APIProtocol { get }

var username: String { get nonmutating set }
var email: String { get nonmutating set }
var randomCode: String { get nonmutating set }
Expand Down
4 changes: 1 addition & 3 deletions Fyreplace/Views/Screens/SettingsScreenProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import PhotosUI
import SwiftUI

@MainActor
protocol SettingsScreenProtocol: ViewProtocol {
var api: APIProtocol { get }

protocol SettingsScreenProtocol: APIViewProtocol {
var token: String { get nonmutating set }
var currentUser: Components.Schemas.User? { get nonmutating set }
var bio: String { get nonmutating set }
Expand Down
7 changes: 6 additions & 1 deletion Fyreplace/Views/ViewProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ protocol ViewProtocol {
}

@MainActor
protocol LoadingViewProtocol: ViewProtocol {
protocol APIViewProtocol: ViewProtocol {
var api: APIProtocol { get }
}

@MainActor
protocol LoadingViewProtocol: APIViewProtocol {
var isLoading: Bool { get nonmutating set }
}

Expand Down

0 comments on commit 284b9ba

Please sign in to comment.