mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Singularize enum type names (#978)
This commit is contained in:
parent
737b179066
commit
bf49a4558c
11 changed files with 23 additions and 23 deletions
|
@ -13,7 +13,7 @@ import Timeline
|
||||||
@MainActor
|
@MainActor
|
||||||
extension View {
|
extension View {
|
||||||
func withAppRouter() -> some View {
|
func withAppRouter() -> some View {
|
||||||
navigationDestination(for: RouterDestinations.self) { destination in
|
navigationDestination(for: RouterDestination.self) { destination in
|
||||||
switch destination {
|
switch destination {
|
||||||
case let .accountDetail(id):
|
case let .accountDetail(id):
|
||||||
AccountDetailView(accountId: id)
|
AccountDetailView(accountId: id)
|
||||||
|
@ -47,7 +47,7 @@ extension View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func withSheetDestinations(sheetDestinations: Binding<SheetDestinations?>) -> some View {
|
func withSheetDestinations(sheetDestinations: Binding<SheetDestination?>) -> some View {
|
||||||
sheet(item: sheetDestinations) { destination in
|
sheet(item: sheetDestinations) { destination in
|
||||||
switch destination {
|
switch destination {
|
||||||
case let .replyToStatusEditor(status):
|
case let .replyToStatusEditor(status):
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Shimmer
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct SupportAppView: View {
|
struct SupportAppView: View {
|
||||||
enum Tips: String, CaseIterable {
|
enum Tip: String, CaseIterable {
|
||||||
case one, two, three, four
|
case one, two, three, four
|
||||||
|
|
||||||
init(productId: String) {
|
init(productId: String) {
|
||||||
|
@ -86,7 +86,7 @@ struct SupportAppView: View {
|
||||||
.shimmering()
|
.shimmering()
|
||||||
} else {
|
} else {
|
||||||
ForEach(products, id: \.productIdentifier) { product in
|
ForEach(products, id: \.productIdentifier) { product in
|
||||||
let tip = Tips(productId: product.productIdentifier)
|
let tip = Tip(productId: product.productIdentifier)
|
||||||
HStack {
|
HStack {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text(tip.title)
|
Text(tip.title)
|
||||||
|
@ -141,7 +141,7 @@ struct SupportAppView: View {
|
||||||
})
|
})
|
||||||
.onAppear {
|
.onAppear {
|
||||||
loadingProducts = true
|
loadingProducts = true
|
||||||
Purchases.shared.getProducts(Tips.allCases.map { $0.productId }) { products in
|
Purchases.shared.getProducts(Tip.allCases.map { $0.productId }) { products in
|
||||||
self.products = products.sorted(by: { $0.price < $1.price })
|
self.products = products.sorted(by: { $0.price < $1.price })
|
||||||
withAnimation {
|
withAnimation {
|
||||||
loadingProducts = false
|
loadingProducts = false
|
||||||
|
|
|
@ -218,7 +218,7 @@ public struct AccountDetailView: View {
|
||||||
private var listsListView: some View {
|
private var listsListView: some View {
|
||||||
Group {
|
Group {
|
||||||
ForEach(currentAccount.sortedLists) { list in
|
ForEach(currentAccount.sortedLists) { list in
|
||||||
NavigationLink(value: RouterDestinations.list(list: list)) {
|
NavigationLink(value: RouterDestination.list(list: list)) {
|
||||||
Text(list.title)
|
Text(list.title)
|
||||||
.font(.scaledHeadline)
|
.font(.scaledHeadline)
|
||||||
.foregroundColor(theme.labelColor)
|
.foregroundColor(theme.labelColor)
|
||||||
|
@ -346,7 +346,7 @@ public struct AccountDetailView: View {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Menu {
|
Menu {
|
||||||
ForEach(MutingDurations.allCases, id: \.rawValue) { duration in
|
ForEach(MutingDuration.allCases, id: \.rawValue) { duration in
|
||||||
Button(duration.description) {
|
Button(duration.description) {
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
enum MutingDurations: Int, CaseIterable {
|
enum MutingDuration: Int, CaseIterable {
|
||||||
case infinite = 0
|
case infinite = 0
|
||||||
case fiveMinutes = 300
|
case fiveMinutes = 300
|
||||||
case thirtyMinutes = 1800
|
case thirtyMinutes = 1800
|
|
@ -3,7 +3,7 @@ import Models
|
||||||
import Network
|
import Network
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
public enum RouterDestinations: Hashable {
|
public enum RouterDestination: Hashable {
|
||||||
case accountDetail(id: String)
|
case accountDetail(id: String)
|
||||||
case accountDetailWithAccount(account: Account)
|
case accountDetailWithAccount(account: Account)
|
||||||
case accountSettingsWithAccount(account: Account, appAccount: AppAccount)
|
case accountSettingsWithAccount(account: Account, appAccount: AppAccount)
|
||||||
|
@ -20,7 +20,7 @@ public enum RouterDestinations: Hashable {
|
||||||
case accountsList(accounts: [Account])
|
case accountsList(accounts: [Account])
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SheetDestinations: Identifiable {
|
public enum SheetDestination: Identifiable {
|
||||||
case newStatusEditor(visibility: Models.Visibility)
|
case newStatusEditor(visibility: Models.Visibility)
|
||||||
case editStatusEditor(status: Status)
|
case editStatusEditor(status: Status)
|
||||||
case replyToStatusEditor(status: Status)
|
case replyToStatusEditor(status: Status)
|
||||||
|
@ -64,12 +64,12 @@ public class RouterPath: ObservableObject {
|
||||||
public var client: Client?
|
public var client: Client?
|
||||||
public var urlHandler: ((URL) -> OpenURLAction.Result)?
|
public var urlHandler: ((URL) -> OpenURLAction.Result)?
|
||||||
|
|
||||||
@Published public var path: [RouterDestinations] = []
|
@Published public var path: [RouterDestination] = []
|
||||||
@Published public var presentedSheet: SheetDestinations?
|
@Published public var presentedSheet: SheetDestination?
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
public func navigate(to: RouterDestinations) {
|
public func navigate(to: RouterDestination) {
|
||||||
path.append(to)
|
path.append(to)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public struct OpenAIClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Prompts {
|
public enum Prompt {
|
||||||
case correct(input: String)
|
case correct(input: String)
|
||||||
case shorten(input: String)
|
case shorten(input: String)
|
||||||
case emphasize(input: String)
|
case emphasize(input: String)
|
||||||
|
@ -89,7 +89,7 @@ public struct OpenAIClient {
|
||||||
|
|
||||||
public init() {}
|
public init() {}
|
||||||
|
|
||||||
public func request(_ prompt: Prompts) async throws -> Response {
|
public func request(_ prompt: Prompt) async throws -> Response {
|
||||||
do {
|
do {
|
||||||
let jsonData = try encoder.encode(prompt.request)
|
let jsonData = try encoder.encode(prompt.request)
|
||||||
var request = URLRequest(url: endpoint)
|
var request = URLRequest(url: endpoint)
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Foundation
|
||||||
import Network
|
import Network
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
enum StatusEditorAIPrompts: CaseIterable {
|
enum StatusEditorAIPrompt: CaseIterable {
|
||||||
case correct, fit, emphasize
|
case correct, fit, emphasize
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
@ -17,7 +17,7 @@ enum StatusEditorAIPrompts: CaseIterable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toRequestPrompt(text: String) -> OpenAIClient.Prompts {
|
func toRequestPrompt(text: String) -> OpenAIClient.Prompt {
|
||||||
switch self {
|
switch self {
|
||||||
case .correct:
|
case .correct:
|
||||||
return .correct(input: text)
|
return .correct(input: text)
|
|
@ -124,7 +124,7 @@ struct StatusEditorAccessoryView: View {
|
||||||
|
|
||||||
private var AIMenu: some View {
|
private var AIMenu: some View {
|
||||||
Menu {
|
Menu {
|
||||||
ForEach(StatusEditorAIPrompts.allCases, id: \.self) { prompt in
|
ForEach(StatusEditorAIPrompt.allCases, id: \.self) { prompt in
|
||||||
Button {
|
Button {
|
||||||
Task {
|
Task {
|
||||||
isLoadingAIRequest = true
|
isLoadingAIRequest = true
|
||||||
|
|
|
@ -483,7 +483,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
|
||||||
|
|
||||||
// MARK: - OpenAI Prompt
|
// MARK: - OpenAI Prompt
|
||||||
|
|
||||||
func runOpenAI(prompt: OpenAIClient.Prompts) async {
|
func runOpenAI(prompt: OpenAIClient.Prompt) async {
|
||||||
do {
|
do {
|
||||||
let client = OpenAIClient()
|
let client = OpenAIClient()
|
||||||
let response = try await client.request(prompt)
|
let response = try await client.request(prompt)
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct StatusRowActionsView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
enum Actions: CaseIterable {
|
enum Action: CaseIterable {
|
||||||
case respond, boost, favorite, bookmark, share
|
case respond, boost, favorite, bookmark, share
|
||||||
|
|
||||||
func iconName(viewModel: StatusRowViewModel, privateBoost: Bool = false) -> String {
|
func iconName(viewModel: StatusRowViewModel, privateBoost: Bool = false) -> String {
|
||||||
|
@ -69,7 +69,7 @@ struct StatusRowActionsView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 12) {
|
VStack(spacing: 12) {
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(Actions.allCases, id: \.self) { action in
|
ForEach(Action.allCases, id: \.self) { action in
|
||||||
if action == .share {
|
if action == .share {
|
||||||
if let urlString = viewModel.status.reblog?.url ?? viewModel.status.url,
|
if let urlString = viewModel.status.reblog?.url ?? viewModel.status.url,
|
||||||
let url = URL(string: urlString)
|
let url = URL(string: urlString)
|
||||||
|
@ -107,7 +107,7 @@ struct StatusRowActionsView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleAction(action: Actions) {
|
private func handleAction(action: Action) {
|
||||||
Task {
|
Task {
|
||||||
if viewModel.isRemote, viewModel.localStatusId == nil || viewModel.localStatus == nil {
|
if viewModel.isRemote, viewModel.localStatusId == nil || viewModel.localStatus == nil {
|
||||||
guard await viewModel.fetchRemoteStatus() else {
|
guard await viewModel.fetchRemoteStatus() else {
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct StatusRowSwipeView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func makeSwipeButtonForRouterPath(action: StatusAction, destination: SheetDestinations) -> some View {
|
private func makeSwipeButtonForRouterPath(action: StatusAction, destination: SheetDestination) -> some View {
|
||||||
Button {
|
Button {
|
||||||
HapticManager.shared.fireHaptic(of: .notification(.success))
|
HapticManager.shared.fireHaptic(of: .notification(.success))
|
||||||
viewModel.routerPath.presentedSheet = destination
|
viewModel.routerPath.presentedSheet = destination
|
||||||
|
|
Loading…
Reference in a new issue