Fixes and improvements

This commit is contained in:
Lumaa 2024-02-20 20:57:07 +01:00
parent af70be22cf
commit 5839ff58cd
5 changed files with 96 additions and 42 deletions

View File

@ -0,0 +1,13 @@
//Made by Lumaa
import SwiftUI
struct AccountRow: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
#Preview {
AccountRow()
}

View File

@ -13,46 +13,81 @@ struct PostInteractor: View {
@Binding var isBookmarked: Bool
var body: some View {
HStack(spacing: 13) {
asyncActionButton(isLiked ? "heart.fill" : "heart") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await likePost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
ViewThatFits {
HStack(spacing: 13) {
asyncActionButton(isLiked ? "heart.fill" : "heart") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await likePost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
}
}
}
actionButton("bubble.right") {
navigator.presentedSheet = .post(content: "@\(status.account.acct)", replyId: status.id)
}
asyncActionButton(isReposted ? "bolt.horizontal.fill" : "bolt.horizontal") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await repostPost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
actionButton("bubble.right") {
navigator.presentedSheet = .post(content: "@\(status.account.acct)", replyId: status.id)
}
}
asyncActionButton(isBookmarked ? "bookmark.fill" : "bookmark") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await bookmarkPost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
asyncActionButton(isReposted ? "bolt.horizontal.fill" : "bolt.horizontal") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await repostPost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
}
}
asyncActionButton(isBookmarked ? "bookmark.fill" : "bookmark") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await bookmarkPost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
}
}
Spacer()
ShareLink(item: URL(string: status.url ?? "https://joinmastodon.org/")!) {
Image(systemName: "square.and.arrow.up")
.font(.system(size: 22))
.padding(.horizontal)
}
.tint(Color(uiColor: UIColor.label))
}
Spacer()
ShareLink(item: URL(string: status.url ?? "https://joinmastodon.org/")!) {
Image(systemName: "square.and.arrow.up")
.font(.title2)
.padding(.horizontal)
HStack(spacing: 13) {
asyncActionButton(isLiked ? "heart.fill" : "heart") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await likePost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
}
}
actionButton("bubble.right") {
navigator.presentedSheet = .post(content: "@\(status.account.acct)", replyId: status.id)
}
asyncActionButton(isReposted ? "bolt.horizontal.fill" : "bolt.horizontal") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await repostPost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
}
}
asyncActionButton(isBookmarked ? "bookmark.fill" : "bookmark") {
do {
HapticManager.playHaptics(haptics: Haptic.tap)
try await bookmarkPost()
} catch {
HapticManager.playHaptics(haptics: Haptic.error)
print("Error: \(error.localizedDescription)")
}
}
}
.tint(Color(uiColor: UIColor.label))
}
.padding(.top)
.onAppear {
@ -108,9 +143,10 @@ struct PostInteractor: View {
action()
} label: {
Image(systemName: image)
.font(.title2)
.font(.system(size: 22))
}
.tint(Color(uiColor: UIColor.label))
.contentShape(Rectangle())
}
@ViewBuilder
@ -121,8 +157,17 @@ struct PostInteractor: View {
}
} label: {
Image(systemName: image)
.font(.title2)
.font(.system(size: 22))
}
.tint(Color(uiColor: UIColor.label))
.contentShape(Rectangle())
}
}
#Preview {
CompactPostView(status: .placeholder())
.environment(Navigator())
.environment(UserPreferences.defaultPreferences)
.environment(UniversalNavigator())
.environment(AccountManager.shared)
}

View File

@ -37,7 +37,6 @@ struct ContentView: View {
}
}
})
.withAppRouter(uniNavigator)
}
.overlay(alignment: .bottom) {
TabsView(selectedTab: $uniNavigator.selectedTab, postButton: {

View File

@ -4,6 +4,7 @@ import SwiftUI
struct AboutView: View {
@ObservedObject private var userPreferences: UserPreferences = .defaultPreferences
@EnvironmentObject private var navigator: Navigator
var body: some View {
List {
@ -60,7 +61,3 @@ struct AboutView: View {
.navigationBarTitleDisplayMode(.large)
}
}
#Preview {
AboutView()
}

View File

@ -6,7 +6,7 @@ import SwiftUI
struct SettingsView: View {
@Environment(UniversalNavigator.self) private var uniNav: UniversalNavigator
@State var navigator: Navigator
@StateObject var navigator: Navigator
var body: some View {
NavigationStack(path: $navigator.path) {