diff --git a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings index 12d56bc5..10f3623a 100644 --- a/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ca.lproj/Localizable.strings @@ -23,6 +23,14 @@ "enum.avatar-position.top" = "Dalt"; "enum.avatar-shape.circle" = "Cercle"; "enum.avatar-shape.rounded" = "Arrodonida"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Tots"; "enum.status-actions-display.no-buttons" = "Sense botons"; "enum.status-actions-display.only-buttons" = "Només els botons"; diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 97e664de..f5b5eebe 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Oben"; "enum.avatar-shape.circle" = "Kreis"; "enum.avatar-shape.rounded" = "Abgerundet"; +"enum.durations.infinite" = "unbegrenzt"; +"enum.durations.fiveMinutes" = "5 Minuten"; +"enum.durations.thirtyMinutes" = "30 Minuten"; +"enum.durations.oneHour" = "1 Stunde"; +"enum.durations.sixHours" = "6 Stunden"; +"enum.durations.oneDay" = "1 Tag"; +"enum.durations.threeDays" = "3 Tage"; +"enum.durations.sevenDays" = "7 Tage"; "enum.status-actions-display.all" = "Alle"; "enum.status-actions-display.no-buttons" = "Keine Buttons"; "enum.status-actions-display.only-buttons" = "Nur Buttons"; diff --git a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings index 42eb9df0..acbe86fc 100644 --- a/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en-GB.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Top"; "enum.avatar-shape.circle" = "Circle"; "enum.avatar-shape.rounded" = "Rounded"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "All"; "enum.status-actions-display.no-buttons" = "No buttons"; "enum.status-actions-display.only-buttons" = "Only buttons"; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index d88ed201..8be6d534 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Top"; "enum.avatar-shape.circle" = "Circle"; "enum.avatar-shape.rounded" = "Rounded"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "All"; "enum.status-actions-display.no-buttons" = "No buttons"; "enum.status-actions-display.only-buttons" = "Only buttons"; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index a27d2227..983393dd 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Arriba"; "enum.avatar-shape.circle" = "Círculo"; "enum.avatar-shape.rounded" = "Redondeado"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Todo"; "enum.status-actions-display.no-buttons" = "Sin botones"; "enum.status-actions-display.only-buttons" = "Sólo botones"; diff --git a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings index 56ccdfe4..2fd4aedd 100644 --- a/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/fr.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "En haut"; "enum.avatar-shape.circle" = "Rond"; "enum.avatar-shape.rounded" = "Arrondi"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Tout"; "enum.status-actions-display.no-buttons" = "Pas de boutons"; "enum.status-actions-display.only-buttons" = "Seulement les boutons"; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index b053e638..923020fe 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "In alto"; "enum.avatar-shape.circle" = "Cerchio"; "enum.avatar-shape.rounded" = "Arrotondata"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Tutti"; "enum.status-actions-display.no-buttons" = "Nessun bottone"; "enum.status-actions-display.only-buttons" = "Solo bottoni"; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index 01f72e90..623eef13 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "トップ"; "enum.avatar-shape.circle" = "サークル"; "enum.avatar-shape.rounded" = "ラウンド"; +"enum.durations.infinite" = "無期限"; +"enum.durations.fiveMinutes" = "5分間"; +"enum.durations.thirtyMinutes" = "30分間"; +"enum.durations.oneHour" = "1時間"; +"enum.durations.sixHours" = "6時間"; +"enum.durations.oneDay" = "1日間"; +"enum.durations.threeDays" = "3日間"; +"enum.durations.sevenDays" = "7日間"; "enum.status-actions-display.all" = "すべて表示"; "enum.status-actions-display.no-buttons" = "ボタン無し"; "enum.status-actions-display.only-buttons" = "ボタンのみ"; diff --git a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings index c8737e4a..76f5f4c1 100644 --- a/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ko.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "본문 위"; "enum.avatar-shape.circle" = "원"; "enum.avatar-shape.rounded" = "둥근 사각형"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "모두 표시"; "enum.status-actions-display.no-buttons" = "표시하지 않음"; "enum.status-actions-display.only-buttons" = "버튼만 표시"; diff --git a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings index 497f0a9c..0cccc278 100644 --- a/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nb.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Topp"; "enum.avatar-shape.circle" = "Sirkel"; "enum.avatar-shape.rounded" = "Avrundet"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Alle"; "enum.status-actions-display.no-buttons" = "Ingen knapper"; "enum.status-actions-display.only-buttons" = "Bare knapper"; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index 78003ef3..5751e169 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Boven"; "enum.avatar-shape.circle" = "Cirkel"; "enum.avatar-shape.rounded" = "Afgerond"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Met tekst"; "enum.status-actions-display.no-buttons" = "Geen knoppen"; "enum.status-actions-display.only-buttons" = "Zonder tekst"; diff --git a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings index 89e5c21c..b3d0b594 100644 --- a/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pl.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Na górze"; "enum.avatar-shape.circle" = "Okrągły"; "enum.avatar-shape.rounded" = "Zaokrąglony"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Wszystko"; "enum.status-actions-display.no-buttons" = "Bez przycisków"; "enum.status-actions-display.only-buttons" = "Tylko przyciski"; diff --git a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings index 30ee3ae2..6cf060a3 100644 --- a/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Topo"; "enum.avatar-shape.circle" = "Círculo"; "enum.avatar-shape.rounded" = "Arredondado"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Todos"; "enum.status-actions-display.no-buttons" = "Sem botões"; "enum.status-actions-display.only-buttons" = "Somente botões"; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index 342bc094..2ce87280 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "Üstte"; "enum.avatar-shape.circle" = "Çember"; "enum.avatar-shape.rounded" = "Yuvarlak"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "Hepsi"; "enum.status-actions-display.no-buttons" = "Butonsuz"; "enum.status-actions-display.only-buttons" = "Sadece Butonlar"; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index bf4048fb..b0bc77ad 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -24,6 +24,14 @@ "enum.avatar-position.top" = "顶部"; "enum.avatar-shape.circle" = "圆形"; "enum.avatar-shape.rounded" = "圆角"; +"enum.durations.infinite" = "infinite"; +"enum.durations.fiveMinutes" = "5 minutes"; +"enum.durations.thirtyMinutes" = "30 minutes"; +"enum.durations.oneHour" = "1 hour"; +"enum.durations.sixHours" = "6 hours"; +"enum.durations.oneDay" = "1 day"; +"enum.durations.threeDays" = "3 days"; +"enum.durations.sevenDays" = "7 days"; "enum.status-actions-display.all" = "图标和文本"; "enum.status-actions-display.no-buttons" = "仅文本"; "enum.status-actions-display.only-buttons" = "仅图标"; diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index 4b19b2d9..80c70f53 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -37,7 +37,7 @@ public struct AccountDetailView: View { public init(account: Account) { _viewModel = StateObject(wrappedValue: .init(account: account)) } - + public var body: some View { ScrollViewReader { proxy in ScrollViewOffsetReader { offset in @@ -403,6 +403,7 @@ public struct AccountDetailView: View { Label("account.action.block", systemImage: "person.crop.circle.badge.xmark") } } + if viewModel.relationship?.muting == true { Button { Task { @@ -416,12 +417,16 @@ public struct AccountDetailView: View { Label("account.action.unmute", systemImage: "speaker") } } else { - Button { - Task { - do { - viewModel.relationship = try await client.post(endpoint: Accounts.mute(id: account.id)) - } catch { - print("Error while muting: \(error.localizedDescription)") + Menu { + ForEach(MutingDurations.allCases, id: \.rawValue) { duration in + Button (duration.description) { + Task { + do { + viewModel.relationship = try await client.post(endpoint: Accounts.mute(id: account.id, json: MuteData(duration: duration.rawValue))) + } catch { + print("Error while muting: \(error.localizedDescription)") + } + } } } } label: { diff --git a/Packages/Account/Sources/Account/MutingDurations.swift b/Packages/Account/Sources/Account/MutingDurations.swift new file mode 100644 index 00000000..49056bfa --- /dev/null +++ b/Packages/Account/Sources/Account/MutingDurations.swift @@ -0,0 +1,33 @@ +import SwiftUI + +enum MutingDurations: Int, CaseIterable { + case infinite = 0 + case fiveMinutes = 300 + case thirtyMinutes = 1_800 + case oneHour = 3_600 + case sixHours = 21_600 + case oneDay = 86_400 + case threeDays = 259_200 + case sevenDays = 604_800 + + public var description: LocalizedStringKey { + switch self { + case .infinite: + return "enum.durations.infinite" + case .fiveMinutes: + return "enum.durations.fiveMinutes" + case .thirtyMinutes: + return "enum.durations.thirtyMinutes" + case .oneHour: + return "enum.durations.oneHour" + case .sixHours: + return "enum.durations.sixHours" + case .oneDay: + return "enum.durations.oneDay" + case .threeDays: + return "enum.durations.threeDays" + case .sevenDays: + return "enum.durations.sevenDays" + } + } +} diff --git a/Packages/Network/Sources/Network/Endpoint/Accounts.swift b/Packages/Network/Sources/Network/Endpoint/Accounts.swift index df33a770..071b7837 100644 --- a/Packages/Network/Sources/Network/Endpoint/Accounts.swift +++ b/Packages/Network/Sources/Network/Endpoint/Accounts.swift @@ -32,9 +32,9 @@ public enum Accounts: Endpoint { case preferences case block(id: String) case unblock(id: String) - case mute(id: String) + case mute(id: String, json: MuteData) case unmute(id: String) - + public func path() -> String { switch self { case let .accounts(id): @@ -75,13 +75,13 @@ public enum Accounts: Endpoint { return "accounts/\(id)/block" case let .unblock(id): return "accounts/\(id)/unblock" - case let .mute(id): + case let .mute(id, _): return "accounts/\(id)/mute" case let .unmute(id): return "accounts/\(id)/unmute" } } - + public func queryItems() -> [URLQueryItem]? { switch self { case let .statuses(_, sinceId, tag, onlyMedia, excludeReplies, pinned): @@ -138,4 +138,21 @@ public enum Accounts: Endpoint { return nil } } + + public var jsonValue: Encodable? { + switch self { + case let .mute(_, json): + return json + default: + return nil + } + } +} + +public struct MuteData: Encodable { + public let duration: Int + + public init(duration: Int) { + self.duration = duration + } }