Skip to content

Commit

Permalink
Merge branch 'main' into iOS-18
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimillian committed Aug 30, 2024
2 parents 5b97f5f + e0eed97 commit 3f6c3a0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 39 deletions.
17 changes: 13 additions & 4 deletions IceCubesApp/App/Tabs/Settings/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -64,6 +64,15 @@ struct AboutView: View {
#endif

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("""
Expand Down
9 changes: 9 additions & 0 deletions IceCubesApp/Resources/Localization/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -41802,6 +41802,9 @@
}
}
}
},
"Privacy Policy" : {

},
"Private" : {
"localizations" : {
Expand Down Expand Up @@ -78620,6 +78623,12 @@
}
}
}
},
"Telemetry" : {

},
"Telemetry by TelemtryDeck" : {

},
"The DeepL API Key is still stored!" : {
"extractionState" : "manual",
Expand Down
29 changes: 23 additions & 6 deletions Packages/Account/Sources/Account/AccountDetailHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import Env
import Models
import NukeUI
import SwiftUI
import AppAccount

@MainActor
struct AccountDetailHeaderView: View {
enum Constants {
static let headerHeight: CGFloat = 200
}

@Environment(\.openWindow) private var openWindow
@Environment(Theme.self) private var theme
@Environment(QuickLook.self) private var quickLook
@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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions Packages/Account/Sources/Account/AccountDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

Expand All @@ -346,4 +352,9 @@ extension AccountDetailViewModel {
reblogs: true))
}
}

private func fetchSubClubAccount(premiumUsername: String) async {
let user = await subClubClient.getUser(username: premiumUsername)
subClubUser = user
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -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: {
Expand All @@ -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: {
Expand All @@ -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")
}
}
}
Expand All @@ -112,7 +94,7 @@ struct NotificationsPolicyView: View {
}
.redacted(reason: policy == nil ? .placeholder : [])
}
.presentationDetents([.medium])
.presentationDetents([.height(500)])
.presentationBackground(.thinMaterial)
}

Expand All @@ -121,6 +103,16 @@ struct NotificationsPolicyView: View {
Text(policy.rawValue.capitalized)
}
}

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 {
Expand Down

0 comments on commit 3f6c3a0

Please sign in to comment.