mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-22 15:16:36 +00:00
Fixed typos & misspells (#88)
* Fixed typos and misspells * Other typos
This commit is contained in:
parent
899ccd8ad7
commit
bb72327f52
48 changed files with 281 additions and 281 deletions
|
@ -9,8 +9,8 @@ import Timeline
|
|||
|
||||
@MainActor
|
||||
extension View {
|
||||
func withAppRouteur() -> some View {
|
||||
navigationDestination(for: RouteurDestinations.self) { destination in
|
||||
func withAppRouter() -> some View {
|
||||
navigationDestination(for: RouterDestinations.self) { destination in
|
||||
switch destination {
|
||||
case let .accountDetail(id):
|
||||
AccountDetailView(accountId: id)
|
||||
|
@ -43,7 +43,7 @@ extension View {
|
|||
StatusEditorView(mode: .replyTo(status: status))
|
||||
.withEnvironments()
|
||||
case let .newStatusEditor(visibility):
|
||||
StatusEditorView(mode: .new(vivibilty: visibility))
|
||||
StatusEditorView(mode: .new(visibility: visibility))
|
||||
.withEnvironments()
|
||||
case let .editStatusEditor(status):
|
||||
StatusEditorView(mode: .edit(status: status))
|
||||
|
|
|
@ -13,7 +13,7 @@ struct QuickLookPreview: UIViewControllerRepresentable {
|
|||
let urls: [URL]
|
||||
|
||||
func makeUIViewController(context: Context) -> UINavigationController {
|
||||
let controller = AppQLPreviewCpntroller()
|
||||
let controller = AppQLPreviewController()
|
||||
controller.dataSource = context.coordinator
|
||||
controller.delegate = context.coordinator
|
||||
let nav = UINavigationController(rootViewController: controller)
|
||||
|
@ -49,7 +49,7 @@ struct QuickLookPreview: UIViewControllerRepresentable {
|
|||
}
|
||||
}
|
||||
|
||||
class AppQLPreviewCpntroller: QLPreviewController {
|
||||
class AppQLPreviewController: QLPreviewController {
|
||||
private var closeButton: UIBarButtonItem {
|
||||
.init(title: "Done", style: .plain, target: self, action: #selector(onCloseButton))
|
||||
}
|
||||
|
|
|
@ -4,25 +4,25 @@ import SafariServices
|
|||
import SwiftUI
|
||||
|
||||
extension View {
|
||||
func withSafariRouteur() -> some View {
|
||||
modifier(SafariRouteur())
|
||||
func withSafariRouter() -> some View {
|
||||
modifier(SafariRouter())
|
||||
}
|
||||
}
|
||||
|
||||
private struct SafariRouteur: ViewModifier {
|
||||
private struct SafariRouter: ViewModifier {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var preferences: UserPreferences
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
@State private var safari: SFSafariViewController?
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
routeurPath.handle(url: url)
|
||||
routerPath.handle(url: url)
|
||||
})
|
||||
.onAppear {
|
||||
routeurPath.urlHandler = { url in
|
||||
routerPath.urlHandler = { url in
|
||||
guard preferences.preferredBrowser == .inAppSafari else { return .systemAction }
|
||||
// SFSafariViewController only supports initial URLs with http:// or https:// schemes.
|
||||
guard let scheme = url.scheme, ["https", "http"].contains(scheme.lowercased()) else {
|
||||
|
|
|
@ -27,7 +27,7 @@ struct SideBarView<Content: View>: View {
|
|||
Button {
|
||||
selectedTab = .profile
|
||||
} label: {
|
||||
AppAccountsSelectorView(routeurPath: RouterPath(),
|
||||
AppAccountsSelectorView(routerPath: RouterPath(),
|
||||
accountCreationEnabled: false,
|
||||
avatarSize: .status)
|
||||
}
|
||||
|
|
|
@ -10,36 +10,36 @@ struct ExploreTab: View {
|
|||
@EnvironmentObject private var preferences: UserPreferences
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@EnvironmentObject private var client: Client
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@StateObject private var routerPath = RouterPath()
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routeurPath.path) {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
ExploreView()
|
||||
.withAppRouteur()
|
||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
statusEditorToolbarItem(routeurPath: routeurPath,
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.withSafariRouteur()
|
||||
.environmentObject(routeurPath)
|
||||
.withSafariRouter()
|
||||
.environmentObject(routerPath)
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
if popToRootTab == .explore {
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
routerPath.client = client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,18 +11,18 @@ struct MessagesTab: View {
|
|||
@EnvironmentObject private var watcher: StreamWatcher
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@StateObject private var routerPath = RouterPath()
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routeurPath.path) {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
ConversationsListView()
|
||||
.withAppRouteur()
|
||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,16 +30,16 @@ struct MessagesTab: View {
|
|||
}
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
if popToRootTab == .messages {
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
routerPath.client = client
|
||||
}
|
||||
.withSafariRouteur()
|
||||
.environmentObject(routeurPath)
|
||||
.withSafariRouter()
|
||||
.environmentObject(routerPath)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,39 +10,39 @@ struct NotificationsTab: View {
|
|||
@EnvironmentObject private var watcher: StreamWatcher
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@EnvironmentObject private var userPreferences: UserPreferences
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@StateObject private var routerPath = RouterPath()
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routeurPath.path) {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
NotificationsListView()
|
||||
.withAppRouteur()
|
||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
statusEditorToolbarItem(routeurPath: routeurPath,
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: userPreferences.serverPreferences?.postVisibility ?? .pub)
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
.id(currentAccount.account?.id)
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
routerPath.client = client
|
||||
watcher.unreadNotificationsCount = 0
|
||||
userPreferences.pushNotificationsCount = 0
|
||||
}
|
||||
.withSafariRouteur()
|
||||
.environmentObject(routeurPath)
|
||||
.withSafariRouter()
|
||||
.environmentObject(routerPath)
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
if popToRootTab == .notifications {
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,19 @@ import SwiftUI
|
|||
struct ProfileTab: View {
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@StateObject private var routerPath = RouterPath()
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routeurPath.path) {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
if let account = currentAccount.account {
|
||||
AccountDetailView(account: account)
|
||||
.withAppRouteur()
|
||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,16 +35,16 @@ struct ProfileTab: View {
|
|||
}
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
if popToRootTab == .messages {
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
routerPath.client = client
|
||||
}
|
||||
.withSafariRouteur()
|
||||
.environmentObject(routeurPath)
|
||||
.withSafariRouter()
|
||||
.environmentObject(routerPath)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,14 +15,14 @@ struct SettingsTabs: View {
|
|||
@EnvironmentObject private var appAccountsManager: AppAccountsManager
|
||||
@EnvironmentObject private var theme: Theme
|
||||
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@StateObject private var routerPath = RouterPath()
|
||||
|
||||
@State private var addAccountSheetPresented = false
|
||||
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routeurPath.path) {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
Form {
|
||||
appSection
|
||||
accountsSection
|
||||
|
@ -33,22 +33,22 @@ struct SettingsTabs: View {
|
|||
.navigationTitle(Text("Settings"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbarBackground(theme.primaryBackgroundColor, for: .navigationBar)
|
||||
.withAppRouteur()
|
||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
routerPath.client = client
|
||||
}
|
||||
.task {
|
||||
if appAccountsManager.currentAccount.oauthToken != nil {
|
||||
await currentInstance.fetchCurrentInstance()
|
||||
}
|
||||
}
|
||||
.withSafariRouteur()
|
||||
.environmentObject(routeurPath)
|
||||
.withSafariRouter()
|
||||
.environmentObject(routerPath)
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
if popToRootTab == .notifications {
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ struct SettingsTabs: View {
|
|||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
Button {
|
||||
routeurPath.presentedSheet = .addRemoteLocalTimeline
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("Add a local timeline", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ struct TimelineTab: View {
|
|||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@EnvironmentObject private var preferences: UserPreferences
|
||||
@EnvironmentObject private var client: Client
|
||||
@StateObject private var routeurPath = RouterPath()
|
||||
@StateObject private var routerPath = RouterPath()
|
||||
@Binding var popToRootTab: Tab
|
||||
|
||||
@State private var didAppear: Bool = false
|
||||
|
@ -28,17 +28,17 @@ struct TimelineTab: View {
|
|||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationStack(path: $routeurPath.path) {
|
||||
NavigationStack(path: $routerPath.path) {
|
||||
TimelineView(timeline: $timeline, scrollToTopSignal: $scrollToTopSignal)
|
||||
.withAppRouteur()
|
||||
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
||||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbar {
|
||||
toolbarView
|
||||
}
|
||||
.id(currentAccount.account?.id)
|
||||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
routerPath.client = client
|
||||
if !didAppear && canFilterTimeline {
|
||||
didAppear = true
|
||||
timeline = client.isAuth ? .home : .federated
|
||||
|
@ -47,7 +47,7 @@ struct TimelineTab: View {
|
|||
await currentAccount.fetchLists()
|
||||
}
|
||||
if !client.isAuth {
|
||||
routeurPath.presentedSheet = .addAccount
|
||||
routerPath.presentedSheet = .addAccount
|
||||
}
|
||||
}
|
||||
.onChange(of: client.isAuth, perform: { isAuth in
|
||||
|
@ -58,18 +58,18 @@ struct TimelineTab: View {
|
|||
})
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
if popToRootTab == .timeline {
|
||||
if routeurPath.path.isEmpty {
|
||||
if routerPath.path.isEmpty {
|
||||
scrollToTopSignal += 1
|
||||
} else {
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
routeurPath.path = []
|
||||
routerPath.path = []
|
||||
}
|
||||
.withSafariRouteur()
|
||||
.environmentObject(routeurPath)
|
||||
.withSafariRouter()
|
||||
.environmentObject(routerPath)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
@ -114,7 +114,7 @@ struct TimelineTab: View {
|
|||
}
|
||||
}
|
||||
Button {
|
||||
routeurPath.presentedSheet = .addRemoteLocalTimeline
|
||||
routerPath.presentedSheet = .addRemoteLocalTimeline
|
||||
} label: {
|
||||
Label("Add a local timeline", systemImage: "badge.plus.radiowaves.right")
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ struct TimelineTab: View {
|
|||
|
||||
private var addAccountButton: some View {
|
||||
Button {
|
||||
routeurPath.presentedSheet = .addAccount
|
||||
routerPath.presentedSheet = .addAccount
|
||||
} label: {
|
||||
Image(systemName: "person.badge.plus")
|
||||
}
|
||||
|
@ -139,10 +139,10 @@ struct TimelineTab: View {
|
|||
if client.isAuth {
|
||||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routeurPath: routeurPath)
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
statusEditorToolbarItem(routeurPath: routeurPath,
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
|
||||
} else {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
|
@ -153,7 +153,7 @@ struct TimelineTab: View {
|
|||
case let .list(list):
|
||||
ToolbarItem {
|
||||
Button {
|
||||
routeurPath.presentedSheet = .listEdit(list: list)
|
||||
routerPath.presentedSheet = .listEdit(list: list)
|
||||
} label: {
|
||||
Image(systemName: "list.bullet")
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import SwiftUI
|
|||
struct AccountDetailHeaderView: View {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var quickLook: QuickLook
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@Environment(\.redactionReasons) private var reasons
|
||||
|
||||
@ObservedObject var viewModel: AccountDetailViewModel
|
||||
|
@ -93,10 +93,10 @@ struct AccountDetailHeaderView: View {
|
|||
} label: {
|
||||
makeCustomInfoLabel(title: "Posts", count: account.statusesCount)
|
||||
}
|
||||
NavigationLink(value: RouteurDestinations.following(id: account.id)) {
|
||||
NavigationLink(value: RouterDestinations.following(id: account.id)) {
|
||||
makeCustomInfoLabel(title: "Following", count: account.followingCount)
|
||||
}
|
||||
NavigationLink(value: RouteurDestinations.followers(id: account.id)) {
|
||||
NavigationLink(value: RouterDestinations.followers(id: account.id)) {
|
||||
makeCustomInfoLabel(title: "Followers", count: account.followersCount)
|
||||
}
|
||||
}.offset(y: 20)
|
||||
|
@ -127,7 +127,7 @@ struct AccountDetailHeaderView: View {
|
|||
.font(.body)
|
||||
.padding(.top, 8)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
routeurPath.handle(url: url)
|
||||
routerPath.handle(url: url)
|
||||
})
|
||||
}
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
|
|
|
@ -14,7 +14,7 @@ public struct AccountDetailView: View {
|
|||
@EnvironmentObject private var preferences: UserPreferences
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
@StateObject private var viewModel: AccountDetailViewModel
|
||||
@State private var scrollOffset: CGFloat = 0
|
||||
|
@ -41,7 +41,7 @@ public struct AccountDetailView: View {
|
|||
} content: {
|
||||
LazyVStack(alignment: .leading) {
|
||||
makeHeaderView(proxy: proxy)
|
||||
familliarFollowers
|
||||
familiarFollowers
|
||||
.offset(y: -36)
|
||||
featuredTagsView
|
||||
.offset(y: -36)
|
||||
|
@ -163,7 +163,7 @@ public struct AccountDetailView: View {
|
|||
if !viewModel.featuredTags.isEmpty {
|
||||
ForEach(viewModel.featuredTags) { tag in
|
||||
Button {
|
||||
routeurPath.navigate(to: .hashTag(tag: tag.name, account: viewModel.accountId))
|
||||
routerPath.navigate(to: .hashTag(tag: tag.name, account: viewModel.accountId))
|
||||
} label: {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text("#\(tag.name)")
|
||||
|
@ -181,18 +181,18 @@ public struct AccountDetailView: View {
|
|||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var familliarFollowers: some View {
|
||||
if !viewModel.familliarFollowers.isEmpty {
|
||||
private var familiarFollowers: some View {
|
||||
if !viewModel.familiarFollowers.isEmpty {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("Also followed by")
|
||||
.font(.headline)
|
||||
.padding(.leading, .layoutPadding)
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
LazyHStack(spacing: 0) {
|
||||
ForEach(viewModel.familliarFollowers) { account in
|
||||
ForEach(viewModel.familiarFollowers) { account in
|
||||
AvatarView(url: account.avatar, size: .badge)
|
||||
.onTapGesture {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||
}
|
||||
.padding(.leading, -4)
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ public struct AccountDetailView: View {
|
|||
private var listsListView: some View {
|
||||
Group {
|
||||
ForEach(currentAccount.lists) { list in
|
||||
NavigationLink(value: RouteurDestinations.list(list: list)) {
|
||||
NavigationLink(value: RouterDestinations.list(list: list)) {
|
||||
HStack {
|
||||
Text(list.title)
|
||||
Spacer()
|
||||
|
@ -349,13 +349,13 @@ public struct AccountDetailView: View {
|
|||
Section(account.acct) {
|
||||
if !viewModel.isCurrentUser {
|
||||
Button {
|
||||
routeurPath.presentedSheet = .mentionStatusEditor(account: account,
|
||||
routerPath.presentedSheet = .mentionStatusEditor(account: account,
|
||||
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
|
||||
} label: {
|
||||
Label("Mention", systemImage: "at")
|
||||
}
|
||||
Button {
|
||||
routeurPath.presentedSheet = .mentionStatusEditor(account: account, visibility: .direct)
|
||||
routerPath.presentedSheet = .mentionStatusEditor(account: account, visibility: .direct)
|
||||
} label: {
|
||||
Label("Message", systemImage: "tray.full")
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ public struct AccountDetailView: View {
|
|||
|
||||
if viewModel.relationship?.following == true {
|
||||
Button {
|
||||
routeurPath.presentedSheet = .listAddAccount(account: account)
|
||||
routerPath.presentedSheet = .listAddAccount(account: account)
|
||||
} label: {
|
||||
Label("Add/Remove from lists", systemImage: "list.bullet")
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||
|
||||
@Published var statusesState: StatusesState = .loading
|
||||
|
||||
@Published var relationship: Relationshionship?
|
||||
@Published var relationship: Relationship?
|
||||
@Published var pinned: [Status] = []
|
||||
@Published var favourites: [Status] = []
|
||||
@Published var bookmarks: [Status] = []
|
||||
|
@ -68,7 +68,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||
private var bookmarksNextPage: LinkHandler?
|
||||
@Published var featuredTags: [FeaturedTag] = []
|
||||
@Published var fields: [Account.Field] = []
|
||||
@Published var familliarFollowers: [Account] = []
|
||||
@Published var familiarFollowers: [Account] = []
|
||||
@Published var selectedTab = Tab.statuses {
|
||||
didSet {
|
||||
switch selectedTab {
|
||||
|
@ -104,8 +104,8 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||
struct AccountData {
|
||||
let account: Account
|
||||
let featuredTags: [FeaturedTag]
|
||||
let relationships: [Relationshionship]
|
||||
let familliarFollowers: [FamilliarAccounts]
|
||||
let relationships: [Relationship]
|
||||
let familiarFollowers: [FamiliarAccounts]
|
||||
}
|
||||
|
||||
func fetchAccount() async {
|
||||
|
@ -119,7 +119,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||
featuredTags = data.featuredTags
|
||||
featuredTags.sort { $0.statusesCountInt > $1.statusesCountInt }
|
||||
relationship = data.relationships.first
|
||||
familliarFollowers = data.familliarFollowers.first?.accounts ?? []
|
||||
familiarFollowers = data.familiarFollowers.first?.accounts ?? []
|
||||
|
||||
} catch {
|
||||
if let account {
|
||||
|
@ -134,17 +134,17 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||
async let account: Account = client.get(endpoint: Accounts.accounts(id: accountId))
|
||||
async let featuredTags: [FeaturedTag] = client.get(endpoint: Accounts.featuredTags(id: accountId))
|
||||
if client.isAuth && !isCurrentUser {
|
||||
async let relationships: [Relationshionship] = client.get(endpoint: Accounts.relationships(ids: [accountId]))
|
||||
async let familliarFollowers: [FamilliarAccounts] = client.get(endpoint: Accounts.familiarFollowers(withAccount: accountId))
|
||||
async let relationships: [Relationship] = client.get(endpoint: Accounts.relationships(ids: [accountId]))
|
||||
async let familiarFollowers: [FamiliarAccounts] = client.get(endpoint: Accounts.familiarFollowers(withAccount: accountId))
|
||||
return try await .init(account: account,
|
||||
featuredTags: featuredTags,
|
||||
relationships: relationships,
|
||||
familliarFollowers: familliarFollowers)
|
||||
familiarFollowers: familiarFollowers)
|
||||
}
|
||||
return try await .init(account: account,
|
||||
featuredTags: featuredTags,
|
||||
relationships: [],
|
||||
familliarFollowers: [])
|
||||
familiarFollowers: [])
|
||||
}
|
||||
|
||||
func fetchStatuses() async {
|
||||
|
|
|
@ -10,9 +10,9 @@ public class AccountsListRowViewModel: ObservableObject {
|
|||
var client: Client?
|
||||
|
||||
@Published var account: Account
|
||||
@Published var relationShip: Relationshionship
|
||||
@Published var relationShip: Relationship
|
||||
|
||||
public init(account: Account, relationShip: Relationshionship) {
|
||||
public init(account: Account, relationShip: Relationship) {
|
||||
self.account = account
|
||||
self.relationShip = relationShip
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class AccountsListRowViewModel: ObservableObject {
|
|||
|
||||
public struct AccountsListRow: View {
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@EnvironmentObject private var client: Client
|
||||
|
||||
@StateObject var viewModel: AccountsListRowViewModel
|
||||
|
@ -43,7 +43,7 @@ public struct AccountsListRow: View {
|
|||
.font(.footnote)
|
||||
.lineLimit(3)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
routeurPath.handle(url: url)
|
||||
routerPath.handle(url: url)
|
||||
})
|
||||
}
|
||||
Spacer()
|
||||
|
@ -58,7 +58,7 @@ public struct AccountsListRow: View {
|
|||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: viewModel.account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: viewModel.account))
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,13 +33,13 @@ class AccountsListViewModel: ObservableObject {
|
|||
|
||||
case loading
|
||||
case display(accounts: [Account],
|
||||
relationships: [Relationshionship],
|
||||
relationships: [Relationship],
|
||||
nextPageState: PagingState)
|
||||
case error(error: Error)
|
||||
}
|
||||
|
||||
private var accounts: [Account] = []
|
||||
private var relationships: [Relationshionship] = []
|
||||
private var relationships: [Relationship] = []
|
||||
|
||||
@Published var state = State.loading
|
||||
|
||||
|
@ -98,7 +98,7 @@ class AccountsListViewModel: ObservableObject {
|
|||
maxId: nextPageId))
|
||||
}
|
||||
accounts.append(contentsOf: newAccounts)
|
||||
let newRelationships: [Relationshionship] =
|
||||
let newRelationships: [Relationship] =
|
||||
try await client.get(endpoint: Accounts.relationships(ids: newAccounts.map { $0.id }))
|
||||
|
||||
relationships.append(contentsOf: newRelationships)
|
|
@ -9,10 +9,10 @@ public class FollowButtonViewModel: ObservableObject {
|
|||
|
||||
public let accountId: String
|
||||
public let shouldDisplayNotify: Bool
|
||||
@Published public private(set) var relationship: Relationshionship
|
||||
@Published public private(set) var relationship: Relationship
|
||||
@Published public private(set) var isUpdating: Bool = false
|
||||
|
||||
public init(accountId: String, relationship: Relationshionship, shouldDisplayNotify: Bool) {
|
||||
public init(accountId: String, relationship: Relationship, shouldDisplayNotify: Bool) {
|
||||
self.accountId = accountId
|
||||
self.relationship = relationship
|
||||
self.shouldDisplayNotify = shouldDisplayNotify
|
||||
|
|
|
@ -4,7 +4,7 @@ import Env
|
|||
import SwiftUI
|
||||
|
||||
public struct AppAccountView: View {
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@EnvironmentObject var appAccounts: AppAccountsManager
|
||||
@StateObject var viewModel: AppAccountViewModel
|
||||
|
||||
|
@ -45,7 +45,7 @@ public struct AppAccountView: View {
|
|||
if appAccounts.currentAccount.id == viewModel.appAccount.id,
|
||||
let account = viewModel.account
|
||||
{
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||
} else {
|
||||
appAccounts.currentAccount = viewModel.appAccount
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@ public struct AppAccountsSelectorView: View {
|
|||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@EnvironmentObject private var appAccounts: AppAccountsManager
|
||||
|
||||
@ObservedObject var routeurPath: RouterPath
|
||||
@ObservedObject var routerPath: RouterPath
|
||||
|
||||
@State private var accountsViewModel: [AppAccountViewModel] = []
|
||||
|
||||
private let accountCreationEnabled: Bool
|
||||
private let avatarSize: AvatarView.Size
|
||||
|
||||
public init(routeurPath: RouterPath,
|
||||
public init(routerPath: RouterPath,
|
||||
accountCreationEnabled: Bool = true,
|
||||
avatarSize: AvatarView.Size = .badge)
|
||||
{
|
||||
self.routeurPath = routeurPath
|
||||
self.routerPath = routerPath
|
||||
self.accountCreationEnabled = accountCreationEnabled
|
||||
self.avatarSize = avatarSize
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public struct AppAccountsSelectorView: View {
|
|||
if let account = currentAccount.account,
|
||||
viewModel.account?.id == account.id
|
||||
{
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||
} else {
|
||||
appAccounts.currentAccount = viewModel.appAccount
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public struct AppAccountsSelectorView: View {
|
|||
if accountCreationEnabled {
|
||||
Divider()
|
||||
Button {
|
||||
routeurPath.presentedSheet = .addAccount
|
||||
routerPath.presentedSheet = .addAccount
|
||||
} label: {
|
||||
Label("Add Account", systemImage: "person.badge.plus")
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import Shimmer
|
|||
import SwiftUI
|
||||
|
||||
public struct ConversationsListView: View {
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@EnvironmentObject private var watcher: StreamWatcher
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var theme: Theme
|
||||
|
|
|
@ -4,10 +4,10 @@ import SwiftUI
|
|||
|
||||
@MainActor
|
||||
public extension View {
|
||||
func statusEditorToolbarItem(routeurPath: RouterPath, visibility: Models.Visibility) -> some ToolbarContent {
|
||||
func statusEditorToolbarItem(routerPath: RouterPath, visibility: Models.Visibility) -> some ToolbarContent {
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
routeurPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||
routerPath.presentedSheet = .newStatusEditor(visibility: visibility)
|
||||
} label: {
|
||||
Image(systemName: "square.and.pencil")
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import Models
|
|||
import SwiftUI
|
||||
|
||||
public struct TagRowView: View {
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
let tag: Tag
|
||||
|
||||
|
@ -24,7 +24,7 @@ public struct TagRowView: View {
|
|||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
routeurPath.navigate(to: .hashTag(tag: tag.name, account: nil))
|
||||
routerPath.navigate(to: .hashTag(tag: tag.name, account: nil))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class PushNotificationsService: ObservableObject {
|
|||
{
|
||||
return data
|
||||
} else {
|
||||
let key = Self.makeRandomeNotificationsAuthKey()
|
||||
let key = Self.makeRandomNotificationsAuthKey()
|
||||
keychain.set(key.base64EncodedString(),
|
||||
forKey: Constants.keychainAuthKey,
|
||||
withAccess: .accessibleAfterFirstUnlock)
|
||||
|
@ -168,7 +168,7 @@ public class PushNotificationsService: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
private static func makeRandomeNotificationsAuthKey() -> Data {
|
||||
private static func makeRandomNotificationsAuthKey() -> Data {
|
||||
let byteCount = 16
|
||||
var bytes = Data(count: byteCount)
|
||||
_ = bytes.withUnsafeMutableBytes { SecRandomCopyBytes(kSecRandomDefault, byteCount, $0.baseAddress!) }
|
||||
|
|
|
@ -3,7 +3,7 @@ import Models
|
|||
import Network
|
||||
import SwiftUI
|
||||
|
||||
public enum RouteurDestinations: Hashable {
|
||||
public enum RouterDestinations: Hashable {
|
||||
case accountDetail(id: String)
|
||||
case accountDetailWithAccount(account: Account)
|
||||
case statusDetail(id: String)
|
||||
|
@ -48,12 +48,12 @@ public class RouterPath: ObservableObject {
|
|||
public var client: Client?
|
||||
public var urlHandler: ((URL) -> OpenURLAction.Result)?
|
||||
|
||||
@Published public var path: [RouteurDestinations] = []
|
||||
@Published public var path: [RouterDestinations] = []
|
||||
@Published public var presentedSheet: SheetDestinations?
|
||||
|
||||
public init() {}
|
||||
|
||||
public func navigate(to: RouteurDestinations) {
|
||||
public func navigate(to: RouterDestinations) {
|
||||
path.append(to)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import SwiftUI
|
|||
public struct ExploreView: View {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
@StateObject private var viewModel = ExploreViewModel()
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class ExploreViewModel: ObservableObject {
|
|||
@Published var results: [String: SearchResults] = [:]
|
||||
@Published var isLoaded = false
|
||||
@Published var suggestedAccounts: [Account] = []
|
||||
@Published var suggestedAccountsRelationShips: [Relationshionship] = []
|
||||
@Published var suggestedAccountsRelationShips: [Relationship] = []
|
||||
@Published var trendingTags: [Tag] = []
|
||||
@Published var trendingStatuses: [Status] = []
|
||||
@Published var trendingLinks: [Card] = []
|
||||
|
@ -126,7 +126,7 @@ class ExploreViewModel: ObservableObject {
|
|||
offset: nil,
|
||||
following: nil),
|
||||
forceVersion: .v2)
|
||||
let relationships: [Relationshionship] =
|
||||
let relationships: [Relationship] =
|
||||
try await client.get(endpoint: Accounts.relationships(ids: results.accounts.map { $0.id }))
|
||||
results.relationships = relationships
|
||||
self.results[searchQuery] = results
|
||||
|
|
|
@ -71,7 +71,7 @@ public struct Account: Codable, Identifiable, Equatable, Hashable {
|
|||
}
|
||||
}
|
||||
|
||||
public struct FamilliarAccounts: Codable {
|
||||
public struct FamiliarAccounts: Codable {
|
||||
public let id: String
|
||||
public let accounts: [Account]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
public struct MediaAttachement: Codable, Identifiable, Hashable {
|
||||
public struct MediaAttachment: Codable, Identifiable, Hashable {
|
||||
public struct MetaContainer: Codable, Equatable {
|
||||
public struct Meta: Codable, Equatable {
|
||||
public let width: Int?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
public struct Relationshionship: Codable {
|
||||
public struct Relationship: Codable {
|
||||
public let id: String
|
||||
public let following: Bool
|
||||
public let showingReblogs: Bool
|
||||
|
@ -15,7 +15,7 @@ public struct Relationshionship: Codable {
|
|||
public let note: String
|
||||
public let notifying: Bool
|
||||
|
||||
public static func placeholder() -> Relationshionship {
|
||||
public static func placeholder() -> Relationship {
|
||||
.init(id: UUID().uuidString,
|
||||
following: false,
|
||||
showingReblogs: false,
|
|
@ -6,7 +6,7 @@ public struct SearchResults: Decodable {
|
|||
}
|
||||
|
||||
public let accounts: [Account]
|
||||
public var relationships: [Relationshionship] = []
|
||||
public var relationships: [Relationship] = []
|
||||
public let statuses: [Status]
|
||||
public let hashtags: [Tag]
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ public struct ServerPreferences: Decodable {
|
|||
public let postVisibility: Visibility?
|
||||
public let postIsSensitive: Bool?
|
||||
public let postLanguage: String?
|
||||
public let autoExpandmedia: AutoExpandMedia?
|
||||
public let autoExpandMedia: AutoExpandMedia?
|
||||
public let autoExpandSpoilers: Bool?
|
||||
|
||||
public enum AutoExpandMedia: String, Decodable {
|
||||
|
@ -17,7 +17,7 @@ public struct ServerPreferences: Decodable {
|
|||
case postVisibility = "posting:default:visibility"
|
||||
case postIsSensitive = "posting:default:sensitive"
|
||||
case postLanguage = "posting:default:language"
|
||||
case autoExpandmedia = "reading:expand:media"
|
||||
case autoExpandMedia = "reading:expand:media"
|
||||
case autoExpandSpoilers = "reading:expand:spoilers"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public protocol AnyStatus {
|
|||
var account: Account { get }
|
||||
var createdAt: ServerDate { get }
|
||||
var editedAt: ServerDate? { get }
|
||||
var mediaAttachments: [MediaAttachement] { get }
|
||||
var mediaAttachments: [MediaAttachment] { get }
|
||||
var mentions: [Mention] { get }
|
||||
var repliesCount: Int { get }
|
||||
var reblogsCount: Int { get }
|
||||
|
@ -65,7 +65,7 @@ public struct Status: AnyStatus, Codable, Identifiable {
|
|||
public let createdAt: ServerDate
|
||||
public let editedAt: ServerDate?
|
||||
public let reblog: ReblogStatus?
|
||||
public let mediaAttachments: [MediaAttachement]
|
||||
public let mediaAttachments: [MediaAttachment]
|
||||
public let mentions: [Mention]
|
||||
public let repliesCount: Int
|
||||
public let reblogsCount: Int
|
||||
|
@ -130,7 +130,7 @@ public struct ReblogStatus: AnyStatus, Codable, Identifiable {
|
|||
public let account: Account
|
||||
public let createdAt: String
|
||||
public let editedAt: ServerDate?
|
||||
public let mediaAttachments: [MediaAttachement]
|
||||
public let mediaAttachments: [MediaAttachment]
|
||||
public let mentions: [Mention]
|
||||
public let repliesCount: Int
|
||||
public let reblogsCount: Int
|
||||
|
|
|
@ -7,7 +7,7 @@ import SwiftUI
|
|||
|
||||
struct NotificationRowView: View {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@Environment(\.redactionReasons) private var reasons
|
||||
|
||||
let notification: Models.Notification
|
||||
|
@ -44,7 +44,7 @@ struct NotificationRowView: View {
|
|||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: notification.account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: notification.account))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ struct NotificationRowView: View {
|
|||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: notification.account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: notification.account))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,13 +103,13 @@ struct NotificationRowView: View {
|
|||
.font(.callout)
|
||||
.foregroundColor(.gray)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
routeurPath.handle(url: url)
|
||||
routerPath.handle(url: url)
|
||||
})
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: notification.account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: notification.account))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ public struct NotificationsListView: View {
|
|||
}
|
||||
|
||||
case .error:
|
||||
ErrorView(title: "An error occured",
|
||||
message: "An error occured while loading your notifications, please retry.",
|
||||
ErrorView(title: "An error occurred",
|
||||
message: "An error occurred while loading your notifications, please retry.",
|
||||
buttonTitle: "Retry") {
|
||||
Task {
|
||||
await viewModel.fetchNotifications()
|
||||
|
|
|
@ -10,7 +10,7 @@ public struct StatusDetailView: View {
|
|||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@EnvironmentObject private var watcher: StreamWatcher
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@Environment(\.openURL) private var openURL
|
||||
@StateObject private var viewModel: StatusDetailViewModel
|
||||
@State private var isLoaded: Bool = false
|
||||
|
@ -63,8 +63,8 @@ public struct StatusDetailView: View {
|
|||
}
|
||||
|
||||
case .error:
|
||||
ErrorView(title: "An error occured",
|
||||
message: "An error occured while this post context, please try again.",
|
||||
ErrorView(title: "An error occurred",
|
||||
message: "An error occurred while this post context, please try again.",
|
||||
buttonTitle: "Retry") {
|
||||
Task {
|
||||
await viewModel.fetch()
|
||||
|
@ -86,7 +86,7 @@ public struct StatusDetailView: View {
|
|||
openURL(url)
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
_ = routeurPath.path.popLast()
|
||||
_ = routerPath.path.popLast()
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.async {
|
|
@ -12,7 +12,7 @@ struct StatusEditorAccessoryView: View {
|
|||
@FocusState<Bool>.Binding var isSpoilerTextFocused: Bool
|
||||
@ObservedObject var viewModel: StatusEditorViewModel
|
||||
|
||||
@State private var isDrafsSheetDisplayed: Bool = false
|
||||
@State private var isDraftsSheetDisplayed: Bool = false
|
||||
@State private var isLanguageSheetDisplayed: Bool = false
|
||||
@State private var languageSearch: String = ""
|
||||
|
||||
|
@ -46,7 +46,7 @@ struct StatusEditorAccessoryView: View {
|
|||
|
||||
if !viewModel.mode.isInShareExtension {
|
||||
Button {
|
||||
isDrafsSheetDisplayed = true
|
||||
isDraftsSheetDisplayed = true
|
||||
} label: {
|
||||
Image(systemName: "archivebox")
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ struct StatusEditorAccessoryView: View {
|
|||
.padding(.vertical, 12)
|
||||
.background(.ultraThinMaterial)
|
||||
}
|
||||
.sheet(isPresented: $isDrafsSheetDisplayed) {
|
||||
.sheet(isPresented: $isDraftsSheetDisplayed) {
|
||||
draftsSheetView
|
||||
}
|
||||
.sheet(isPresented: $isLanguageSheetDisplayed, content: {
|
||||
|
@ -133,7 +133,7 @@ struct StatusEditorAccessoryView: View {
|
|||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
.onTapGesture {
|
||||
viewModel.insertStatusText(text: draft)
|
||||
isDrafsSheetDisplayed = false
|
||||
isDraftsSheetDisplayed = false
|
||||
}
|
||||
}
|
||||
.onDelete { indexes in
|
||||
|
@ -144,7 +144,7 @@ struct StatusEditorAccessoryView: View {
|
|||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button("Cancel", action: { isDrafsSheetDisplayed = false })
|
||||
Button("Cancel", action: { isDraftsSheetDisplayed = false })
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
|
|
|
@ -19,7 +19,7 @@ struct StatusEditorMediaEditView: View {
|
|||
}
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
Section {
|
||||
if let url = container.mediaAttachement?.url {
|
||||
if let url = container.mediaAttachment?.url {
|
||||
AsyncImage(
|
||||
url: url,
|
||||
content: { image in
|
||||
|
@ -43,7 +43,7 @@ struct StatusEditorMediaEditView: View {
|
|||
.scrollContentBackground(.hidden)
|
||||
.background(theme.secondaryBackgroundColor)
|
||||
.onAppear {
|
||||
imageDescription = container.mediaAttachement?.description ?? ""
|
||||
imageDescription = container.mediaAttachment?.description ?? ""
|
||||
}
|
||||
.navigationTitle("Edit Image")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
|
|
@ -19,10 +19,10 @@ struct StatusEditorMediaView: View {
|
|||
ZStack(alignment: .bottomTrailing) {
|
||||
if container.image != nil {
|
||||
makeLocalImage(container: container)
|
||||
} else if let url = container.mediaAttachement?.url ?? container.mediaAttachement?.previewUrl {
|
||||
} else if let url = container.mediaAttachment?.url ?? container.mediaAttachment?.previewUrl {
|
||||
makeLazyImage(url: url)
|
||||
}
|
||||
if container.mediaAttachement?.description?.isEmpty == false {
|
||||
if container.mediaAttachment?.description?.isEmpty == false {
|
||||
altMarker
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ struct StatusEditorMediaView: View {
|
|||
ZStack(alignment: .center) {
|
||||
Image(uiImage: container.image!)
|
||||
.resizable()
|
||||
.blur(radius: container.mediaAttachement == nil ? 20 : 0)
|
||||
.blur(radius: container.mediaAttachment == nil ? 20 : 0)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: 150, height: 150)
|
||||
.cornerRadius(8)
|
||||
|
@ -69,7 +69,7 @@ struct StatusEditorMediaView: View {
|
|||
}
|
||||
.buttonStyle(.bordered)
|
||||
}
|
||||
} else if container.mediaAttachement == nil {
|
||||
} else if container.mediaAttachment == nil {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ struct StatusEditorMediaView: View {
|
|||
Button {
|
||||
editingContainer = container
|
||||
} label: {
|
||||
Label(container.mediaAttachement?.description?.isEmpty == false ?
|
||||
Label(container.mediaAttachment?.description?.isEmpty == false ?
|
||||
"Edit description" : "Add description",
|
||||
systemImage: "pencil.line")
|
||||
}
|
||||
|
|
|
@ -41,14 +41,14 @@ public struct StatusEditorView: View {
|
|||
.placeholder("What's on your mind")
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
StatusEditorMediaView(viewModel: viewModel)
|
||||
if let status = viewModel.embededStatus {
|
||||
StatusEmbededView(status: status)
|
||||
if let status = viewModel.embeddedStatus {
|
||||
StatusEmbeddedView(status: status)
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
.disabled(true)
|
||||
} else if let status = viewModel.replyToStatus {
|
||||
Divider()
|
||||
.padding(.top, 20)
|
||||
StatusEmbededView(status: status)
|
||||
StatusEmbeddedView(status: status)
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
.disabled(true)
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ public struct StatusEditorView: View {
|
|||
private var accountHeaderView: some View {
|
||||
if let account = currentAccount.account {
|
||||
HStack {
|
||||
AppAccountsSelectorView(routeurPath: RouterPath(),
|
||||
AppAccountsSelectorView(routerPath: RouterPath(),
|
||||
accountCreationEnabled: false,
|
||||
avatarSize: .status)
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
|
@ -210,10 +210,10 @@ public struct StatusEditorView: View {
|
|||
prompt.label
|
||||
}
|
||||
}
|
||||
if let backup = viewModel.backupStatustext {
|
||||
if let backup = viewModel.backupStatusText {
|
||||
Button {
|
||||
viewModel.replaceTextWith(text: backup.string)
|
||||
viewModel.backupStatustext = nil
|
||||
viewModel.backupStatusText = nil
|
||||
} label: {
|
||||
Label("Restore previous text", systemImage: "arrow.uturn.right")
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
struct ImageContainer: Identifiable {
|
||||
let id = UUID().uuidString
|
||||
let image: UIImage?
|
||||
let mediaAttachement: MediaAttachement?
|
||||
let mediaAttachment: MediaAttachment?
|
||||
let error: Error?
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
@Published var backupStatustext: NSAttributedString?
|
||||
@Published var backupStatusText: NSAttributedString?
|
||||
|
||||
@Published var showPoll: Bool = false
|
||||
@Published var pollVotingFrequency = PollVotingFrequency.oneVote
|
||||
|
@ -52,7 +52,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
|
||||
@Published var mediasImages: [ImageContainer] = []
|
||||
@Published var replyToStatus: Status?
|
||||
@Published var embededStatus: Status?
|
||||
@Published var embeddedStatus: Status?
|
||||
var canPost: Bool {
|
||||
statusText.length > 0 || !mediasImages.isEmpty
|
||||
}
|
||||
|
@ -68,8 +68,8 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
@Published var selectedLanguage: String?
|
||||
private var currentSuggestionRange: NSRange?
|
||||
|
||||
private var embededStatusURL: URL? {
|
||||
return embededStatus?.reblog?.url ?? embededStatus?.url
|
||||
private var embeddedStatusURL: URL? {
|
||||
return embeddedStatus?.reblog?.url ?? embeddedStatus?.url
|
||||
}
|
||||
|
||||
private var uploadTask: Task<Void, Never>?
|
||||
|
@ -129,7 +129,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
visibility: visibility,
|
||||
inReplyToId: mode.replyToStatus?.id,
|
||||
spoilerText: spoilerOn ? spoilerText : nil,
|
||||
mediaIds: mediasImages.compactMap { $0.mediaAttachement?.id },
|
||||
mediaIds: mediasImages.compactMap { $0.mediaAttachment?.id },
|
||||
poll: pollData,
|
||||
language: selectedLanguage)
|
||||
switch mode {
|
||||
|
@ -185,10 +185,10 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
spoilerOn = !status.spoilerText.isEmpty
|
||||
spoilerText = status.spoilerText
|
||||
visibility = status.visibility
|
||||
mediasImages = status.mediaAttachments.map { .init(image: nil, mediaAttachement: $0, error: nil) }
|
||||
mediasImages = status.mediaAttachments.map { .init(image: nil, mediaAttachment: $0, error: nil) }
|
||||
case let .quote(status):
|
||||
embededStatus = status
|
||||
if let url = embededStatusURL {
|
||||
embeddedStatus = status
|
||||
if let url = embeddedStatusURL {
|
||||
statusText = .init(string: "\n\nFrom: @\(status.reblog?.account.acct ?? status.account.acct)\n\(url)")
|
||||
selectedRange = .init(location: 0, length: 0)
|
||||
}
|
||||
|
@ -243,16 +243,16 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
range: NSRange(location: range.location, length: range.length))
|
||||
}
|
||||
|
||||
var attachementsToRemove: [NSRange] = []
|
||||
statusText.enumerateAttribute(.attachment, in: range) { attachement, _, _ in
|
||||
if let attachement = attachement as? NSTextAttachment, let image = attachement.image {
|
||||
attachementsToRemove.append(range)
|
||||
mediasImages.append(.init(image: image, mediaAttachement: nil, error: nil))
|
||||
var attachmentsToRemove: [NSRange] = []
|
||||
statusText.enumerateAttribute(.attachment, in: range) { attachment, _, _ in
|
||||
if let attachment = attachment as? NSTextAttachment, let image = attachment.image {
|
||||
attachmentsToRemove.append(range)
|
||||
mediasImages.append(.init(image: image, mediaAttachment: nil, error: nil))
|
||||
}
|
||||
}
|
||||
if !attachementsToRemove.isEmpty {
|
||||
if !attachmentsToRemove.isEmpty {
|
||||
processMediasToUpload()
|
||||
for range in attachementsToRemove {
|
||||
for range in attachmentsToRemove {
|
||||
statusText.removeAttribute(.attachment, range: range)
|
||||
}
|
||||
}
|
||||
|
@ -261,23 +261,23 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
|
||||
private func processItemsProvider(items: [NSItemProvider]) {
|
||||
Task {
|
||||
var initalText: String = ""
|
||||
var initialText: String = ""
|
||||
for item in items {
|
||||
if let identifiter = item.registeredTypeIdentifiers.first,
|
||||
let handledItemType = StatusEditorUTTypeSupported(rawValue: identifiter)
|
||||
if let identifier = item.registeredTypeIdentifiers.first,
|
||||
let handledItemType = StatusEditorUTTypeSupported(rawValue: identifier)
|
||||
{
|
||||
do {
|
||||
let content = try await handledItemType.loadItemContent(item: item)
|
||||
if let text = content as? String {
|
||||
initalText += "\(text) "
|
||||
initialText += "\(text) "
|
||||
} else if let image = content as? UIImage {
|
||||
mediasImages.append(.init(image: image, mediaAttachement: nil, error: nil))
|
||||
mediasImages.append(.init(image: image, mediaAttachment: nil, error: nil))
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
if !initalText.isEmpty {
|
||||
statusText = .init(string: initalText)
|
||||
if !initialText.isEmpty {
|
||||
statusText = .init(string: initialText)
|
||||
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
|
||||
}
|
||||
if !mediasImages.isEmpty {
|
||||
|
@ -293,11 +293,11 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
private func checkEmbed() {
|
||||
if let url = embededStatusURL,
|
||||
if let url = embeddedStatusURL,
|
||||
!statusText.string.contains(url.absoluteString)
|
||||
{
|
||||
embededStatus = nil
|
||||
mode = .new(vivibilty: visibility)
|
||||
embeddedStatus = nil
|
||||
mode = .new(visibility: visibility)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
if var text = response.choices.first?.text {
|
||||
text.removeFirst()
|
||||
text.removeFirst()
|
||||
backupStatustext = statusText
|
||||
backupStatusText = statusText
|
||||
replaceTextWith(text: text)
|
||||
}
|
||||
} catch {}
|
||||
|
@ -383,10 +383,10 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
if let data = try await media.loadTransferable(type: Data.self),
|
||||
let image = UIImage(data: data)
|
||||
{
|
||||
medias.append(.init(image: image, mediaAttachement: nil, error: nil))
|
||||
medias.append(.init(image: image, mediaAttachment: nil, error: nil))
|
||||
}
|
||||
} catch {
|
||||
medias.append(.init(image: nil, mediaAttachement: nil, error: error))
|
||||
medias.append(.init(image: nil, mediaAttachment: nil, error: error))
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
|
@ -411,37 +411,37 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
func upload(container: ImageContainer) async {
|
||||
if let index = indexOf(container: container) {
|
||||
let originalContainer = mediasImages[index]
|
||||
let newContainer = ImageContainer(image: originalContainer.image, mediaAttachement: nil, error: nil)
|
||||
let newContainer = ImageContainer(image: originalContainer.image, mediaAttachment: nil, error: nil)
|
||||
mediasImages[index] = newContainer
|
||||
do {
|
||||
if let data = originalContainer.image?.jpegData(compressionQuality: 0.90) {
|
||||
let uploadedMedia = try await uploadMedia(data: data)
|
||||
if let index = indexOf(container: newContainer) {
|
||||
mediasImages[index] = .init(image: mode.isInShareExtension ? originalContainer.image : nil,
|
||||
mediaAttachement: uploadedMedia,
|
||||
mediaAttachment: uploadedMedia,
|
||||
error: nil)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
if let index = indexOf(container: newContainer) {
|
||||
mediasImages[index] = .init(image: originalContainer.image, mediaAttachement: nil, error: error)
|
||||
mediasImages[index] = .init(image: originalContainer.image, mediaAttachment: nil, error: error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func addDescription(container: ImageContainer, description: String) async {
|
||||
guard let client, let attachment = container.mediaAttachement else { return }
|
||||
guard let client, let attachment = container.mediaAttachment else { return }
|
||||
if let index = indexOf(container: container) {
|
||||
do {
|
||||
let media: MediaAttachement = try await client.put(endpoint: Media.media(id: attachment.id,
|
||||
let media: MediaAttachment = try await client.put(endpoint: Media.media(id: attachment.id,
|
||||
description: description))
|
||||
mediasImages[index] = .init(image: nil, mediaAttachement: media, error: nil)
|
||||
mediasImages[index] = .init(image: nil, mediaAttachment: media, error: nil)
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
private func uploadMedia(data: Data) async throws -> MediaAttachement? {
|
||||
private func uploadMedia(data: Data) async throws -> MediaAttachment? {
|
||||
guard let client else { return nil }
|
||||
return try await client.mediaUpload(endpoint: Media.medias,
|
||||
version: .v2,
|
||||
|
|
|
@ -4,7 +4,7 @@ import UIKit
|
|||
public extension StatusEditorViewModel {
|
||||
enum Mode {
|
||||
case replyTo(status: Status)
|
||||
case new(vivibilty: Visibility)
|
||||
case new(visibility: Visibility)
|
||||
case edit(status: Status)
|
||||
case quote(status: Status)
|
||||
case mention(account: Account, visibility: Visibility)
|
||||
|
|
|
@ -4,7 +4,7 @@ import Models
|
|||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
public struct StatusEmbededView: View {
|
||||
public struct StatusEmbeddedView: View {
|
||||
@EnvironmentObject private var theme: Theme
|
||||
|
||||
public let status: Status
|
||||
|
|
|
@ -25,8 +25,8 @@ public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
|
|||
.padding(.vertical, .dividerPadding)
|
||||
}
|
||||
case .error:
|
||||
ErrorView(title: "An error occured",
|
||||
message: "An error occured while loading posts, please try again.",
|
||||
ErrorView(title: "An error occurred",
|
||||
message: "An error occurred while loading posts, please try again.",
|
||||
buttonTitle: "Retry") {
|
||||
Task {
|
||||
await fetcher.fetchStatuses()
|
||||
|
|
|
@ -7,7 +7,7 @@ import SwiftUI
|
|||
struct StatusActionsView: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@ObservedObject var viewModel: StatusRowViewModel
|
||||
|
||||
let generator = UINotificationFeedbackGenerator()
|
||||
|
@ -119,7 +119,7 @@ struct StatusActionsView: View {
|
|||
|
||||
if viewModel.favouritesCount > 0 {
|
||||
Divider()
|
||||
NavigationLink(value: RouteurDestinations.favouritedBy(id: viewModel.status.id)) {
|
||||
NavigationLink(value: RouterDestinations.favouritedBy(id: viewModel.status.id)) {
|
||||
Text("\(viewModel.favouritesCount) favorites")
|
||||
.font(.callout)
|
||||
Spacer()
|
||||
|
@ -128,7 +128,7 @@ struct StatusActionsView: View {
|
|||
}
|
||||
if viewModel.reblogsCount > 0 {
|
||||
Divider()
|
||||
NavigationLink(value: RouteurDestinations.rebloggedBy(id: viewModel.status.id)) {
|
||||
NavigationLink(value: RouterDestinations.rebloggedBy(id: viewModel.status.id)) {
|
||||
Text("\(viewModel.reblogsCount) boosts")
|
||||
.font(.callout)
|
||||
Spacer()
|
||||
|
@ -142,7 +142,7 @@ struct StatusActionsView: View {
|
|||
generator.notificationOccurred(.success)
|
||||
switch action {
|
||||
case .respond:
|
||||
routeurPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
case .favourite:
|
||||
if viewModel.isFavourited {
|
||||
await viewModel.unFavourite()
|
||||
|
|
|
@ -10,7 +10,7 @@ public struct StatusMediaPreviewView: View {
|
|||
@EnvironmentObject private var quickLook: QuickLook
|
||||
@EnvironmentObject private var theme: Theme
|
||||
|
||||
public let attachements: [MediaAttachement]
|
||||
public let attachments: [MediaAttachment]
|
||||
public let sensitive: Bool
|
||||
public let isNotifications: Bool
|
||||
|
||||
|
@ -30,13 +30,13 @@ public struct StatusMediaPreviewView: View {
|
|||
if theme.statusDisplayStyle == .compact {
|
||||
return 100
|
||||
}
|
||||
if attachements.count == 1 {
|
||||
if attachments.count == 1 {
|
||||
return 300
|
||||
}
|
||||
return attachements.count > 2 ? 100 : 200
|
||||
return attachments.count > 2 ? 100 : 200
|
||||
}
|
||||
|
||||
private func size(for media: MediaAttachement) -> CGSize? {
|
||||
private func size(for media: MediaAttachment) -> CGSize? {
|
||||
if isNotifications {
|
||||
return .init(width: 50, height: 50)
|
||||
}
|
||||
|
@ -62,30 +62,30 @@ public struct StatusMediaPreviewView: View {
|
|||
|
||||
public var body: some View {
|
||||
Group {
|
||||
if attachements.count == 1, let attachement = attachements.first {
|
||||
makeFeaturedImagePreview(attachement: attachement)
|
||||
if attachments.count == 1, let attachment = attachments.first {
|
||||
makeFeaturedImagePreview(attachment: attachment)
|
||||
.onTapGesture {
|
||||
Task {
|
||||
await quickLook.prepareFor(urls: attachements.compactMap { $0.url }, selectedURL: attachement.url!)
|
||||
await quickLook.prepareFor(urls: attachments.compactMap { $0.url }, selectedURL: attachment.url!)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if isNotifications || theme.statusDisplayStyle == .compact {
|
||||
HStack {
|
||||
makeAttachementView(for: 0)
|
||||
makeAttachementView(for: 1)
|
||||
makeAttachementView(for: 2)
|
||||
makeAttachementView(for: 3)
|
||||
makeAttachmentView(for: 0)
|
||||
makeAttachmentView(for: 1)
|
||||
makeAttachmentView(for: 2)
|
||||
makeAttachmentView(for: 3)
|
||||
}
|
||||
} else {
|
||||
VStack {
|
||||
HStack {
|
||||
makeAttachementView(for: 0)
|
||||
makeAttachementView(for: 1)
|
||||
makeAttachmentView(for: 0)
|
||||
makeAttachmentView(for: 1)
|
||||
}
|
||||
HStack {
|
||||
makeAttachementView(for: 2)
|
||||
makeAttachementView(for: 3)
|
||||
makeAttachmentView(for: 2)
|
||||
makeAttachmentView(for: 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ public struct StatusMediaPreviewView: View {
|
|||
Text(altTextDisplayed ?? "")
|
||||
}
|
||||
.onAppear {
|
||||
if sensitive && preferences.serverPreferences?.autoExpandmedia == .hideSensitive {
|
||||
if sensitive && preferences.serverPreferences?.autoExpandMedia == .hideSensitive {
|
||||
isHidingMedia = true
|
||||
} else if preferences.serverPreferences?.autoExpandmedia == .hideAll {
|
||||
} else if preferences.serverPreferences?.autoExpandMedia == .hideAll {
|
||||
isHidingMedia = true
|
||||
} else {
|
||||
isHidingMedia = false
|
||||
|
@ -120,18 +120,18 @@ public struct StatusMediaPreviewView: View {
|
|||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func makeAttachementView(for index: Int) -> some View {
|
||||
if attachements.count > index {
|
||||
makePreview(attachement: attachements[index])
|
||||
private func makeAttachmentView(for index: Int) -> some View {
|
||||
if attachments.count > index {
|
||||
makePreview(attachment: attachments[index])
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func makeFeaturedImagePreview(attachement: MediaAttachement) -> some View {
|
||||
switch attachement.supportedType {
|
||||
private func makeFeaturedImagePreview(attachment: MediaAttachment) -> some View {
|
||||
switch attachment.supportedType {
|
||||
case .image:
|
||||
if theme.statusDisplayStyle == .large,
|
||||
let size = size(for: attachement),
|
||||
let size = size(for: attachment),
|
||||
UIDevice.current.userInterfaceIdiom != .pad,
|
||||
UIDevice.current.userInterfaceIdiom != .mac
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ public struct StatusMediaPreviewView: View {
|
|||
let newSize = imageSize(from: size,
|
||||
newWidth: availableWidth)
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
LazyImage(url: attachement.url) { state in
|
||||
LazyImage(url: attachment.url) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizingMode(.aspectFill)
|
||||
|
@ -156,7 +156,7 @@ public struct StatusMediaPreviewView: View {
|
|||
if sensitive {
|
||||
cornerSensitiveButton
|
||||
}
|
||||
if let alt = attachement.description, !alt.isEmpty, !isNotifications {
|
||||
if let alt = attachment.description, !alt.isEmpty, !isNotifications {
|
||||
Button {
|
||||
altTextDisplayed = alt
|
||||
isAltAlertDisplayed = true
|
||||
|
@ -170,7 +170,7 @@ public struct StatusMediaPreviewView: View {
|
|||
}
|
||||
} else {
|
||||
AsyncImage(
|
||||
url: attachement.url,
|
||||
url: attachment.url,
|
||||
content: { image in
|
||||
image
|
||||
.resizable()
|
||||
|
@ -187,7 +187,7 @@ public struct StatusMediaPreviewView: View {
|
|||
)
|
||||
}
|
||||
case .gifv, .video, .audio:
|
||||
if let url = attachement.url {
|
||||
if let url = attachment.url {
|
||||
VideoPlayerView(viewModel: .init(url: url))
|
||||
.frame(height: imageMaxHeight)
|
||||
}
|
||||
|
@ -197,14 +197,14 @@ public struct StatusMediaPreviewView: View {
|
|||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func makePreview(attachement: MediaAttachement) -> some View {
|
||||
if let type = attachement.supportedType {
|
||||
private func makePreview(attachment: MediaAttachment) -> some View {
|
||||
if let type = attachment.supportedType {
|
||||
Group {
|
||||
GeometryReader { proxy in
|
||||
switch type {
|
||||
case .image:
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
LazyImage(url: attachement.url) { state in
|
||||
LazyImage(url: attachment.url) { state in
|
||||
if let image = state.image {
|
||||
image
|
||||
.resizingMode(.aspectFill)
|
||||
|
@ -222,7 +222,7 @@ public struct StatusMediaPreviewView: View {
|
|||
if sensitive {
|
||||
cornerSensitiveButton
|
||||
}
|
||||
if let alt = attachement.description, !alt.isEmpty, !isNotifications {
|
||||
if let alt = attachment.description, !alt.isEmpty, !isNotifications {
|
||||
Button {
|
||||
altTextDisplayed = alt
|
||||
isAltAlertDisplayed = true
|
||||
|
@ -236,7 +236,7 @@ public struct StatusMediaPreviewView: View {
|
|||
}
|
||||
}
|
||||
case .gifv, .video, .audio:
|
||||
if let url = attachement.url {
|
||||
if let url = attachment.url {
|
||||
VideoPlayerView(viewModel: .init(url: url))
|
||||
.frame(width: isNotifications ? imageMaxHeight : proxy.frame(in: .local).width)
|
||||
.frame(height: imageMaxHeight)
|
||||
|
@ -248,7 +248,7 @@ public struct StatusMediaPreviewView: View {
|
|||
}
|
||||
.onTapGesture {
|
||||
Task {
|
||||
await quickLook.prepareFor(urls: attachements.compactMap { $0.url }, selectedURL: attachement.url!)
|
||||
await quickLook.prepareFor(urls: attachments.compactMap { $0.url }, selectedURL: attachment.url!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import SwiftUI
|
|||
|
||||
struct StatusRowContextMenu: View {
|
||||
@EnvironmentObject private var account: CurrentAccount
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
|
||||
@Environment(\.openURL) var openURL
|
||||
|
||||
|
@ -41,7 +41,7 @@ struct StatusRowContextMenu: View {
|
|||
systemImage: "bookmark")
|
||||
}
|
||||
Button {
|
||||
routeurPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
|
||||
} label: {
|
||||
Label("Reply", systemImage: "arrowshape.turn.up.left")
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ struct StatusRowContextMenu: View {
|
|||
|
||||
if viewModel.status.visibility == .pub, !viewModel.isRemote {
|
||||
Button {
|
||||
routeurPath.presentedSheet = .quoteStatusEditor(status: viewModel.status)
|
||||
routerPath.presentedSheet = .quoteStatusEditor(status: viewModel.status)
|
||||
} label: {
|
||||
Label("Quote this post", systemImage: "quote.bubble")
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ struct StatusRowContextMenu: View {
|
|||
Label(viewModel.isPinned ? "Unpin" : "Pin", systemImage: viewModel.isPinned ? "pin.fill" : "pin")
|
||||
}
|
||||
Button {
|
||||
routeurPath.presentedSheet = .editStatusEditor(status: viewModel.status)
|
||||
routerPath.presentedSheet = .editStatusEditor(status: viewModel.status)
|
||||
} label: {
|
||||
Label("Edit", systemImage: "pencil")
|
||||
}
|
||||
|
@ -100,12 +100,12 @@ struct StatusRowContextMenu: View {
|
|||
} else if !viewModel.isRemote {
|
||||
Section(viewModel.status.account.acct) {
|
||||
Button {
|
||||
routeurPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.account, visibility: .pub)
|
||||
routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.account, visibility: .pub)
|
||||
} label: {
|
||||
Label("Mention", systemImage: "at")
|
||||
}
|
||||
Button {
|
||||
routeurPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.account, visibility: .direct)
|
||||
routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.account, visibility: .direct)
|
||||
} label: {
|
||||
Label("Message", systemImage: "tray.full")
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public struct StatusRowView: View {
|
|||
@EnvironmentObject private var account: CurrentAccount
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var routeurPath: RouterPath
|
||||
@EnvironmentObject private var routerPath: RouterPath
|
||||
@StateObject var viewModel: StatusRowViewModel
|
||||
|
||||
public init(viewModel: StatusRowViewModel) {
|
||||
|
@ -34,7 +34,7 @@ public struct StatusRowView: View {
|
|||
let status: AnyStatus = viewModel.status.reblog ?? viewModel.status
|
||||
{
|
||||
Button {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: status.account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: status.account))
|
||||
} label: {
|
||||
AvatarView(url: status.account.avatar, size: .status)
|
||||
}
|
||||
|
@ -51,16 +51,16 @@ public struct StatusRowView: View {
|
|||
.tint(viewModel.isFocused ? theme.tintColor : .gray)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
viewModel.navigateToDetail(routeurPath: routeurPath)
|
||||
viewModel.navigateToDetail(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
viewModel.client = client
|
||||
if !viewModel.isCompact, viewModel.embededStatus == nil {
|
||||
if !viewModel.isCompact, viewModel.embeddedStatus == nil {
|
||||
Task {
|
||||
await viewModel.loadEmbededStatus()
|
||||
await viewModel.loadEmbeddedStatus()
|
||||
}
|
||||
}
|
||||
if preferences.serverPreferences?.autoExpandSpoilers == true {
|
||||
|
@ -74,7 +74,7 @@ public struct StatusRowView: View {
|
|||
Color.clear
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
viewModel.navigateToDetail(routeurPath: routeurPath)
|
||||
viewModel.navigateToDetail(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,10 +112,10 @@ public struct StatusRowView: View {
|
|||
.onTapGesture {
|
||||
if viewModel.isRemote, let url = viewModel.status.account.url {
|
||||
Task {
|
||||
await routeurPath.navigateToAccountFrom(url: url)
|
||||
await routerPath.navigateToAccountFrom(url: url)
|
||||
}
|
||||
} else {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: viewModel.status.account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: viewModel.status.account))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ public struct StatusRowView: View {
|
|||
.onTapGesture {
|
||||
if viewModel.isRemote {
|
||||
Task {
|
||||
await routeurPath.navigateToAccountFrom(url: mention.url)
|
||||
await routerPath.navigateToAccountFrom(url: mention.url)
|
||||
}
|
||||
} else {
|
||||
routeurPath.navigate(to: .accountDetail(id: mention.id))
|
||||
routerPath.navigate(to: .accountDetail(id: mention.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,10 +154,10 @@ public struct StatusRowView: View {
|
|||
Button {
|
||||
if viewModel.isRemote, let url = status.account.url {
|
||||
Task {
|
||||
await routeurPath.navigateToAccountFrom(url: url)
|
||||
await routerPath.navigateToAccountFrom(url: url)
|
||||
}
|
||||
} else {
|
||||
routeurPath.navigate(to: .accountDetailWithAccount(account: status.account))
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: status.account))
|
||||
}
|
||||
} label: {
|
||||
accountView(status: status)
|
||||
|
@ -169,7 +169,7 @@ public struct StatusRowView: View {
|
|||
makeStatusContentView(status: status)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
viewModel.navigateToDetail(routeurPath: routeurPath)
|
||||
viewModel.navigateToDetail(routerPath: routerPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,16 +194,16 @@ public struct StatusRowView: View {
|
|||
EmojiTextApp(status.content.asMarkdown, emojis: status.emojis)
|
||||
.font(.body)
|
||||
.environment(\.openURL, OpenURLAction { url in
|
||||
routeurPath.handleStatus(status: status, url: url)
|
||||
routerPath.handleStatus(status: status, url: url)
|
||||
})
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !reasons.contains(.placeholder) {
|
||||
if !viewModel.isCompact, !viewModel.isEmbedLoading, let embed = viewModel.embededStatus {
|
||||
StatusEmbededView(status: embed)
|
||||
if !viewModel.isCompact, !viewModel.isEmbedLoading, let embed = viewModel.embeddedStatus {
|
||||
StatusEmbeddedView(status: embed)
|
||||
} else if viewModel.isEmbedLoading, !viewModel.isCompact {
|
||||
StatusEmbededView(status: .placeholder())
|
||||
StatusEmbeddedView(status: .placeholder())
|
||||
.redacted(reason: .placeholder)
|
||||
.shimmering()
|
||||
}
|
||||
|
@ -216,21 +216,21 @@ public struct StatusRowView: View {
|
|||
if !status.mediaAttachments.isEmpty {
|
||||
if theme.statusDisplayStyle == .compact {
|
||||
HStack {
|
||||
StatusMediaPreviewView(attachements: status.mediaAttachments,
|
||||
StatusMediaPreviewView(attachments: status.mediaAttachments,
|
||||
sensitive: status.sensitive,
|
||||
isNotifications: viewModel.isCompact)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 4)
|
||||
} else {
|
||||
StatusMediaPreviewView(attachements: status.mediaAttachments,
|
||||
StatusMediaPreviewView(attachments: status.mediaAttachments,
|
||||
sensitive: status.sensitive,
|
||||
isNotifications: viewModel.isCompact)
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
if let card = status.card,
|
||||
viewModel.embededStatus?.url != status.card?.url,
|
||||
viewModel.embeddedStatus?.url != status.card?.url,
|
||||
status.mediaAttachments.isEmpty,
|
||||
!viewModel.isEmbedLoading,
|
||||
theme.statusDisplayStyle == .large
|
||||
|
|
|
@ -18,7 +18,7 @@ public class StatusRowViewModel: ObservableObject {
|
|||
@Published var isBookmarked: Bool
|
||||
@Published var reblogsCount: Int
|
||||
@Published var repliesCount: Int
|
||||
@Published var embededStatus: Status?
|
||||
@Published var embeddedStatus: Status?
|
||||
@Published var displaySpoiler: Bool = false
|
||||
@Published var isEmbedLoading: Bool = true
|
||||
@Published var isFiltered: Bool = false
|
||||
|
@ -59,15 +59,15 @@ public class StatusRowViewModel: ObservableObject {
|
|||
isFiltered = filter != nil
|
||||
}
|
||||
|
||||
func navigateToDetail(routeurPath: RouterPath) {
|
||||
func navigateToDetail(routerPath: RouterPath) {
|
||||
if isRemote, let url = status.reblog?.url ?? status.url {
|
||||
routeurPath.navigate(to: .remoteStatusDetail(url: url))
|
||||
routerPath.navigate(to: .remoteStatusDetail(url: url))
|
||||
} else {
|
||||
routeurPath.navigate(to: .statusDetail(id: status.reblog?.id ?? status.id))
|
||||
routerPath.navigate(to: .statusDetail(id: status.reblog?.id ?? status.id))
|
||||
}
|
||||
}
|
||||
|
||||
func loadEmbededStatus() async {
|
||||
func loadEmbeddedStatus() async {
|
||||
guard let client,
|
||||
let urls = status.content.findStatusesURLs(),
|
||||
!urls.isEmpty,
|
||||
|
@ -93,7 +93,7 @@ public class StatusRowViewModel: ObservableObject {
|
|||
embed = results.statuses.first
|
||||
}
|
||||
withAnimation {
|
||||
embededStatus = embed
|
||||
embeddedStatus = embed
|
||||
isEmbedLoading = false
|
||||
}
|
||||
} catch {
|
||||
|
|
Loading…
Reference in a new issue