Merge branch 'main' into iOS-18

This commit is contained in:
Thomas Ricouard 2024-08-30 11:42:58 +02:00
commit 3f6c3a024a
5 changed files with 77 additions and 39 deletions

View file

@ -30,19 +30,19 @@ struct AboutView: View {
#if !targetEnvironment(macCatalyst) && !os(visionOS)
HStack {
Spacer()
Image(uiImage: .init(named: "AppIconAlternate0")!)
Image(uiImage: .init(named: "AppIconAlternate0") ?? .init())
.resizable()
.frame(width: 50, height: 50)
.cornerRadius(4)
Image(uiImage: .init(named: "AppIconAlternate4")!)
Image(uiImage: .init(named: "AppIconAlternate4") ?? .init())
.resizable()
.frame(width: 50, height: 50)
.cornerRadius(4)
Image(uiImage: .init(named: "AppIconAlternate17")!)
Image(uiImage: .init(named: "AppIconAlternate17") ?? .init())
.resizable()
.frame(width: 50, height: 50)
.cornerRadius(4)
Image(uiImage: .init(named: "AppIconAlternate23")!)
Image(uiImage: .init(named: "AppIconAlternate23") ?? .init())
.resizable()
.frame(width: 50, height: 50)
.cornerRadius(4)
@ -65,6 +65,15 @@ struct AboutView: View {
followAccountsSection
Section("Telemetry") {
Link(destination: .init(string: "https://telemetrydeck.com")!) {
Label("Telemetry by TelemtryDeck", systemImage: "link")
}
Link(destination: .init(string: "https://telemetrydeck.com/privacy/")!) {
Label("Privacy Policy", systemImage: "checkmark.shield")
}
}
Section {
Text("""
[EmojiText](https://github.com/divadretlaw/EmojiText)

View file

@ -41802,6 +41802,9 @@
}
}
}
},
"Privacy Policy" : {
},
"Private" : {
"localizations" : {
@ -78620,6 +78623,12 @@
}
}
}
},
"Telemetry" : {
},
"Telemetry by TelemtryDeck" : {
},
"The DeepL API Key is still stored!" : {
"extractionState" : "manual",

View file

@ -4,6 +4,7 @@ import Env
import Models
import NukeUI
import SwiftUI
import AppAccount
@MainActor
struct AccountDetailHeaderView: View {
@ -17,8 +18,11 @@ struct AccountDetailHeaderView: View {
@Environment(RouterPath.self) private var routerPath
@Environment(CurrentAccount.self) private var currentAccount
@Environment(StreamWatcher.self) private var watcher
@Environment(AppAccountsManager.self) private var appAccount
@Environment(\.redactionReasons) private var reasons
@Environment(\.isSupporter) private var isSupporter: Bool
@Environment(\.openURL) private var openURL
@Environment(\.colorScheme) private var colorScheme
var viewModel: AccountDetailViewModel
let account: Account
@ -241,7 +245,7 @@ struct AccountDetailHeaderView: View {
movedToView
joinedAtView
if viewModel.account?.isPremiumAccount == true && viewModel.relationship?.following == false || viewModel.account?.isLinkedToPremiumAccount == true && viewModel.premiumRelationship?.following == false {
tipView
subscribeButton
}
}
.accessibilityElement(children: .contain)
@ -342,18 +346,31 @@ struct AccountDetailHeaderView: View {
}
@ViewBuilder
private var tipView: some View {
private var subscribeButton: some View {
Button {
isTipSheetPresented = true
shouldListenToPremiumTimer = true
if let subscription = viewModel.subClubUser?.subscription,
let accountName = appAccount.currentAccount.accountName,
let premiumUsername = account.premiumUsername,
let url = URL(string: "https://\(AppInfo.premiumInstance)/@\(premiumUsername)/subscribe?callback=icecubesapp://subclub&id=@\(accountName)&amount=\(subscription.unitAmount)&currency=\(subscription.currency)&theme=\(colorScheme)") {
openURL(url)
} else {
isTipSheetPresented = true
shouldListenToPremiumTimer = true
}
Task {
if viewModel.account?.isLinkedToPremiumAccount == true {
try? await viewModel.followPremiumAccount()
}
try? await viewModel.followButtonViewModel?.follow()
}
} label: {
Text("$ Subscribe")
if let subscription = viewModel.subClubUser?.subscription {
Text("Subscribe \(subscription.formattedAmount) / month")
} else {
Text("$ Subscribe")
}
}
.buttonStyle(.bordered)
.padding(.top, 8)

View file

@ -79,8 +79,11 @@ import SwiftUI
var fields: [Account.Field] = []
var familiarFollowers: [Account] = []
// Sub.club stuff
var premiumAccount: Account?
var premiumRelationship: Relationship?
var subClubUser: SubClubUser?
private let subClubClient = SubClubClient()
var selectedTab = Tab.statuses {
didSet {
@ -333,9 +336,12 @@ extension AccountDetailViewModel {
forceVersion: .v2)
if let premiumAccount = results?.accounts.first {
self.premiumAccount = premiumAccount
await fetchSubClubAccount(premiumUsername: premiumAccount.username)
let relationships: [Relationship] = try await client.get(endpoint: Accounts.relationships(ids: [premiumAccount.id]))
self.premiumRelationship = relationships.first
}
} else if fromAccount.isPremiumAccount {
await fetchSubClubAccount(premiumUsername: fromAccount.username)
}
}
@ -346,4 +352,9 @@ extension AccountDetailViewModel {
reblogs: true))
}
}
private func fetchSubClubAccount(premiumUsername: String) async {
let user = await subClubClient.getUser(username: premiumUsername)
subClubUser = user
}
}

View file

@ -25,12 +25,8 @@ struct NotificationsPolicyView: View {
})) {
pickerMenu
} label: {
VStack(alignment: .leading) {
Text("notifications.content-filter.peopleYouDontFollow")
Text("Until you manually approve them")
.foregroundStyle(.secondary)
.font(.footnote)
}
makePickerLabel(title: "notifications.content-filter.peopleYouDontFollow",
subtitle: "Until you manually approve them")
}
Picker(selection: .init(get: {
@ -41,12 +37,8 @@ struct NotificationsPolicyView: View {
})) {
pickerMenu
} label: {
VStack(alignment: .leading) {
Text("notifications.content-filter.peopleNotFollowingYou")
Text("And following you for less than 3 days")
.foregroundStyle(.secondary)
.font(.footnote)
}
makePickerLabel(title: "notifications.content-filter.peopleNotFollowingYou",
subtitle: "And following you for less than 3 days")
}
Picker(selection: .init(get: {
@ -57,12 +49,8 @@ struct NotificationsPolicyView: View {
})) {
pickerMenu
} label: {
VStack(alignment: .leading) {
Text("notifications.content-filter.newAccounts")
Text("Created within the past 30 days")
.foregroundStyle(.secondary)
.font(.footnote)
}
makePickerLabel(title: "notifications.content-filter.newAccounts",
subtitle: "Created within the past 30 days")
}
Picker(selection: .init(get: {
@ -73,12 +61,8 @@ struct NotificationsPolicyView: View {
})) {
pickerMenu
} label: {
VStack(alignment: .leading) {
Text("notifications.content-filter.privateMentions")
Text("Unless it's in reply to your own mention or if you follow the sender")
.foregroundStyle(.secondary)
.font(.footnote)
}
makePickerLabel(title: "notifications.content-filter.privateMentions",
subtitle: "Unless it's in reply to your own mention or if you follow the sender")
}
Picker(selection: .init(get: {
@ -90,10 +74,8 @@ struct NotificationsPolicyView: View {
pickerMenu
} label: {
VStack(alignment: .leading) {
Text("Moderated accounts")
Text("Limited by server moderators")
.foregroundStyle(.secondary)
.font(.footnote)
makePickerLabel(title: "Moderated accounts",
subtitle: "Limited by server moderators")
}
}
}
@ -112,7 +94,7 @@ struct NotificationsPolicyView: View {
}
.redacted(reason: policy == nil ? .placeholder : [])
}
.presentationDetents([.medium])
.presentationDetents([.height(500)])
.presentationBackground(.thinMaterial)
}
@ -122,6 +104,16 @@ struct NotificationsPolicyView: View {
}
}
private func makePickerLabel(title: LocalizedStringKey, subtitle: LocalizedStringKey) -> some View {
VStack(alignment: .leading) {
Text(title)
.font(.callout)
Text(subtitle)
.foregroundStyle(.secondary)
.font(.footnote)
}
}
private func getPolicy() async {
defer {
isUpdating = false