mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-03-14 22:22:41 +00:00
Code cleanup
This commit is contained in:
parent
3e14a92b7d
commit
4783422b3e
8 changed files with 29 additions and 30 deletions
|
@ -176,7 +176,6 @@ extension View {
|
|||
.environment(PushNotificationsService.shared)
|
||||
.environment(AppAccountsManager.shared.currentClient)
|
||||
.environment(QuickLook.shared)
|
||||
.environment(TipedUsers.shared)
|
||||
}
|
||||
|
||||
func withModelContainer() -> some View {
|
||||
|
|
|
@ -25,7 +25,6 @@ extension IceCubesApp {
|
|||
.environment(pushNotificationsService)
|
||||
.environment(appIntentService)
|
||||
.environment(\.isSupporter, isSupporter)
|
||||
.environment(TipedUsers.shared)
|
||||
.sheet(item: $quickLook.selectedMediaAttachment) { selectedMediaAttachment in
|
||||
MediaUIView(selectedAttachment: selectedMediaAttachment,
|
||||
attachments: quickLook.mediaAttachments)
|
||||
|
|
|
@ -20,7 +20,6 @@ private struct SafariRouter: ViewModifier {
|
|||
@Environment(UserPreferences.self) private var preferences
|
||||
@Environment(RouterPath.self) private var routerPath
|
||||
@Environment(AppAccountsManager.self) private var appAccount
|
||||
@Environment(TipedUsers.self) private var tipedUsers
|
||||
|
||||
#if !os(visionOS)
|
||||
@State private var safariManager = InAppSafariManager()
|
||||
|
@ -38,7 +37,6 @@ private struct SafariRouter: ViewModifier {
|
|||
guard !isSecondaryColumn else { return }
|
||||
if url.absoluteString == "icecubesapp://socialproxy" {
|
||||
safariManager.dismiss()
|
||||
TipedUsers.shared.tipedUserCount += 1
|
||||
return
|
||||
}
|
||||
let urlString = url.absoluteString.replacingOccurrences(of: AppInfo.scheme, with: "https://")
|
||||
|
@ -56,7 +54,9 @@ private struct SafariRouter: ViewModifier {
|
|||
UIApplication.shared.open(url)
|
||||
return .handled
|
||||
}
|
||||
} else if url.host() == AppInfo.premiumInstance, let accountName = appAccount.currentAccount.accountName {
|
||||
} else if url.query()?.contains("callback=") == false,
|
||||
url.host() == AppInfo.premiumInstance,
|
||||
let accountName = appAccount.currentAccount.accountName {
|
||||
let newURL = url.appending(queryItems: [
|
||||
.init(name: "callback", value: "icecubesapp://socialproxy"),
|
||||
.init(name: "id", value: "@\(accountName)")
|
||||
|
|
|
@ -337,7 +337,7 @@ struct AccountDetailHeaderView: View {
|
|||
.padding(.bottom, 4)
|
||||
.sheet(isPresented: $isTipSheetPresented) {
|
||||
if let account = viewModel.account {
|
||||
TipSheetView(account: account)
|
||||
PremiumAcccountSubsciptionSheetView(account: account)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,20 +6,19 @@ import WrappingHStack
|
|||
import AppAccount
|
||||
|
||||
@MainActor
|
||||
struct TipSheetView: View {
|
||||
struct PremiumAcccountSubsciptionSheetView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(Theme.self) private var theme: Theme
|
||||
@Environment(TipedUsers.self) private var tipedUSers: TipedUsers
|
||||
@Environment(\.openURL) private var openURL
|
||||
@Environment(AppAccountsManager.self) private var appAccount: AppAccountsManager
|
||||
|
||||
@State private var selectedTip: Int?
|
||||
@State private var isSubscibeSelected: Bool = false
|
||||
|
||||
private enum TipState: Int, Equatable {
|
||||
private enum SheetState: Int, Equatable {
|
||||
case selection, preparing, webview
|
||||
}
|
||||
|
||||
@State private var state: TipState = .selection
|
||||
@State private var state: SheetState = .selection
|
||||
@State private var animationsending: Bool = false
|
||||
|
||||
let account: Account
|
||||
|
@ -61,7 +60,7 @@ struct TipSheetView: View {
|
|||
Text("Subscribe to @\(account.username) to get access to exclusive content!")
|
||||
Button {
|
||||
withAnimation(.easeInOut(duration: 0.5)) {
|
||||
selectedTip = 500
|
||||
isSubscibeSelected = true
|
||||
}
|
||||
} label: {
|
||||
Text("$5 / month")
|
||||
|
@ -77,7 +76,7 @@ struct TipSheetView: View {
|
|||
|
||||
Spacer()
|
||||
|
||||
if selectedTip != nil {
|
||||
if isSubscibeSelected {
|
||||
HStack(alignment: .top) {
|
||||
Text("Subscribe")
|
||||
.font(.headline)
|
||||
|
@ -88,7 +87,6 @@ struct TipSheetView: View {
|
|||
.frame(maxWidth: .infinity)
|
||||
.background(theme.tintColor.opacity(0.5))
|
||||
.onTapGesture {
|
||||
tipedUSers.usersIds.append(account.id)
|
||||
withAnimation {
|
||||
state = .preparing
|
||||
}
|
||||
|
@ -123,9 +121,8 @@ struct TipSheetView: View {
|
|||
.fontWeight(.bold)
|
||||
.onAppear {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
if let selectedTip,
|
||||
let accountName = appAccount.currentAccount.accountName,
|
||||
let url = URL(string: "https://\(AppInfo.premiumInstance)/subscribe/to/\(account.username)?callback=icecubesapp://socialproxy&id=@\(accountName)&amount=\(selectedTip)¤cy=USD") {
|
||||
if let accountName = appAccount.currentAccount.accountName,
|
||||
let url = URL(string: "https://\(AppInfo.premiumInstance)/subscribe/to/\(account.username)?callback=icecubesapp://socialproxy&id=@\(accountName)&amount=\(500)¤cy=USD") {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import Foundation
|
||||
|
||||
@Observable
|
||||
@MainActor
|
||||
public class TipedUsers {
|
||||
public var usersIds: [String] = []
|
||||
|
||||
public var tipedUserCount: Int = 0
|
||||
|
||||
static public let shared = TipedUsers()
|
||||
|
||||
private init() { }
|
||||
}
|
|
@ -66,6 +66,7 @@ public struct StatusRowView: View {
|
|||
} else {
|
||||
if !isCompact && context != .detail {
|
||||
Group {
|
||||
StatusRowPremiumView(viewModel: viewModel)
|
||||
StatusRowTagView(viewModel: viewModel)
|
||||
StatusRowReblogView(viewModel: viewModel)
|
||||
StatusRowReplyView(viewModel: viewModel)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import DesignSystem
|
||||
import Env
|
||||
import SwiftUI
|
||||
|
||||
struct StatusRowPremiumView: View {
|
||||
let viewModel: StatusRowViewModel
|
||||
|
||||
var body: some View {
|
||||
if viewModel.status.account.isProAccount {
|
||||
Text("From a subscribed premium account")
|
||||
.font(.scaledFootnote)
|
||||
.foregroundStyle(.secondary)
|
||||
.fontWeight(.semibold)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue