mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Remove diff tool backup file
This commit is contained in:
parent
d2ed73ca51
commit
c0e0b6184f
@ -1,191 +0,0 @@
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
struct PostListView: View {
|
||||
@EnvironmentObject var model: WriteFreelyModel
|
||||
@Environment(\.managedObjectContext) var managedObjectContext
|
||||
|
||||
@State private var postCount: Int = 0
|
||||
@State private var filteredListViewId: Int = 0
|
||||
|
||||
var selectedCollection: WFACollection?
|
||||
var showAllPosts: Bool
|
||||
|
||||
#if os(iOS)
|
||||
private var frameHeight: CGFloat {
|
||||
var height: CGFloat = 50
|
||||
let bottom = UIApplication.shared.windows.first?.safeAreaInsets.bottom ?? 0
|
||||
height += bottom
|
||||
return height
|
||||
}
|
||||
#endif
|
||||
|
||||
var body: some View {
|
||||
#if os(iOS)
|
||||
ZStack(alignment: .bottom) {
|
||||
PostListFilteredView(
|
||||
collection: selectedCollection,
|
||||
showAllPosts: showAllPosts,
|
||||
postCount: $postCount
|
||||
)
|
||||
<<<<<<< HEAD
|
||||
.navigationTitle(
|
||||
showAllPosts ? "All Posts" : selectedCollection?.title ?? (
|
||||
model.account.server == "https://write.as" ? "Anonymous" : "Drafts"
|
||||
)
|
||||
=======
|
||||
.id(self.filteredListViewId)
|
||||
.navigationTitle(
|
||||
model.showAllPosts ? "All Posts" : model.selectedCollection?.title ?? (
|
||||
model.account.server == "https://write.as" ? "Anonymous" : "Drafts"
|
||||
>>>>>>> c9322d1 (Invalidate PostListView on didBecomeActive)
|
||||
)
|
||||
)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
// We have to add a Spacer as a sibling view to the Button in some kind of Stack, so that any
|
||||
// a11y modifiers are applied as expected: bug report filed as FB8956392.
|
||||
ZStack {
|
||||
Spacer()
|
||||
Button(action: {
|
||||
let managedPost = model.editor.generateNewLocalPost(withFont: model.preferences.font)
|
||||
withAnimation {
|
||||
self.model.showAllPosts = false
|
||||
self.model.selectedPost = managedPost
|
||||
}
|
||||
}, label: {
|
||||
ZStack {
|
||||
Image("does.not.exist")
|
||||
.accessibilityHidden(true)
|
||||
Image(systemName: "square.and.pencil")
|
||||
.accessibilityHidden(true)
|
||||
.imageScale(.large) // These modifiers compensate for the resizing
|
||||
.padding(.vertical, 12) // done to the Image (and the button tap target)
|
||||
.padding(.leading, 12) // by the SwiftUI layout system from adding a
|
||||
.padding(.trailing, 8) // Spacer in this ZStack (FB8956392).
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
})
|
||||
.accessibilityLabel(Text("Compose"))
|
||||
.accessibilityHint(Text("Compose a new local draft"))
|
||||
}
|
||||
}
|
||||
}
|
||||
VStack {
|
||||
HStack(spacing: 0) {
|
||||
Button(action: {
|
||||
model.isPresentingSettingsView = true
|
||||
}, label: {
|
||||
Image(systemName: "gear")
|
||||
.padding(.vertical, 4)
|
||||
.padding(.horizontal, 8)
|
||||
})
|
||||
.accessibilityLabel(Text("Settings"))
|
||||
.accessibilityHint(Text("Open the Settings sheet"))
|
||||
.sheet(
|
||||
isPresented: $model.isPresentingSettingsView,
|
||||
onDismiss: { model.isPresentingSettingsView = false },
|
||||
content: {
|
||||
SettingsView()
|
||||
.environmentObject(model)
|
||||
}
|
||||
)
|
||||
Spacer()
|
||||
Text(postCount == 1 ? "\(postCount) post" : "\(postCount) posts")
|
||||
.foregroundColor(.secondary)
|
||||
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||
Alert(
|
||||
title: Text("Connection Error"),
|
||||
message: Text("""
|
||||
There is no internet connection at the moment. Please reconnect or try again later.
|
||||
"""),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
)
|
||||
})
|
||||
Spacer()
|
||||
if model.isProcessingRequest {
|
||||
ProgressView()
|
||||
.padding(.vertical, 4)
|
||||
.padding(.horizontal, 8)
|
||||
} else {
|
||||
Button(action: {
|
||||
DispatchQueue.main.async {
|
||||
model.fetchUserCollections()
|
||||
model.fetchUserPosts()
|
||||
}
|
||||
}, label: {
|
||||
Image(systemName: "arrow.clockwise")
|
||||
.padding(.vertical, 4)
|
||||
.padding(.horizontal, 8)
|
||||
})
|
||||
.accessibilityLabel(Text("Refresh Posts"))
|
||||
.accessibilityHint(Text("Fetch changes from the server"))
|
||||
.disabled(!model.account.isLoggedIn)
|
||||
}
|
||||
}
|
||||
.padding(.top, 8)
|
||||
.padding(.horizontal, 8)
|
||||
Spacer()
|
||||
}
|
||||
.frame(height: frameHeight)
|
||||
.background(Color(UIColor.systemGray5))
|
||||
.overlay(Divider(), alignment: .top)
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
|
||||
// We use this to invalidate and refresh the view, to make sure we show any new posts that were created
|
||||
// in an extension, for example.
|
||||
withAnimation {
|
||||
self.filteredListViewId += 1
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.onAppear {
|
||||
model.selectedCollection = selectedCollection
|
||||
model.showAllPosts = showAllPosts
|
||||
}
|
||||
#else
|
||||
PostListFilteredView(
|
||||
collection: selectedCollection,
|
||||
showAllPosts: showAllPosts,
|
||||
postCount: $postCount
|
||||
)
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .primaryAction) {
|
||||
if model.selectedPost != nil {
|
||||
ActivePostToolbarView(activePost: model.selectedPost!)
|
||||
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
|
||||
Alert(
|
||||
title: Text("Connection Error"),
|
||||
message: Text("""
|
||||
There is no internet connection at the moment. \
|
||||
Please reconnect or try again later.
|
||||
"""),
|
||||
dismissButton: .default(Text("OK"), action: {
|
||||
model.isPresentingNetworkErrorAlert = false
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle(
|
||||
showAllPosts ? "All Posts" : selectedCollection?.title ?? (
|
||||
model.account.server == "https://write.as" ? "Anonymous" : "Drafts"
|
||||
)
|
||||
)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
struct PostListView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let context = LocalStorageManager.persistentContainer.viewContext
|
||||
let model = WriteFreelyModel()
|
||||
|
||||
return PostListView(showAllPosts: true)
|
||||
.environment(\.managedObjectContext, context)
|
||||
.environmentObject(model)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user