Move bottom bar back to PostListView

Fixes a bug where tapping the new-post button creates the new local draft, but doesn’t automatically load it in the post editor until you open, and then dismiss, the settings sheet.
This commit is contained in:
Angelo Stavrow 2021-01-04 12:58:35 -05:00
parent 2a00a4d6ba
commit a1b3ece294
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
3 changed files with 40 additions and 66 deletions

View File

@ -9,6 +9,15 @@ struct PostListView: View {
@State var showAllPosts: Bool = false @State var showAllPosts: Bool = false
@State private var postCount: Int = 0 @State private var postCount: Int = 0
#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 { var body: some View {
#if os(iOS) #if os(iOS)
ZStack(alignment: .bottom) { ZStack(alignment: .bottom) {
@ -49,7 +58,37 @@ struct PostListView: View {
}) })
} }
} }
PostListBottomBarView(postCount: $postCount) VStack {
HStack(spacing: 0) {
Button(action: {
model.isPresentingSettingsView = true
}, label: {
Image(systemName: "gear")
})
Spacer()
Text(postCount == 1 ? "\(postCount) post" : "\(postCount) posts")
.foregroundColor(.secondary)
Spacer()
if model.isProcessingRequest {
ProgressView()
} else {
Button(action: {
DispatchQueue.main.async {
model.fetchUserCollections()
model.fetchUserPosts()
}
}, label: {
Image(systemName: "arrow.clockwise")
})
.disabled(!model.account.isLoggedIn)
}
}
.padding()
Spacer()
}
.frame(height: frameHeight)
.background(Color(UIColor.systemGray5))
.overlay(Divider(), alignment: .top)
} }
.ignoresSafeArea() .ignoresSafeArea()
#else //if os(macOS) #else //if os(macOS)

View File

@ -79,7 +79,6 @@
17D4F39F2514F0E500517CE6 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F39D2514F0E500517CE6 /* OpenSans-Regular.ttf */; }; 17D4F39F2514F0E500517CE6 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F39D2514F0E500517CE6 /* OpenSans-Regular.ttf */; };
17D4F3A52514F1E900517CE6 /* Hack-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F3A42514F1E900517CE6 /* Hack-Regular.ttf */; }; 17D4F3A52514F1E900517CE6 /* Hack-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F3A42514F1E900517CE6 /* Hack-Regular.ttf */; };
17D4F3A62514F1E900517CE6 /* Hack-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F3A42514F1E900517CE6 /* Hack-Regular.ttf */; }; 17D4F3A62514F1E900517CE6 /* Hack-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 17D4F3A42514F1E900517CE6 /* Hack-Regular.ttf */; };
17DB9C7D25A3582F0030ECC0 /* PostListBottomBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DB9C7C25A3582F0030ECC0 /* PostListBottomBarView.swift */; };
17DF329D24C87D3500BCE2E3 /* Tests_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF329C24C87D3500BCE2E3 /* Tests_iOS.swift */; }; 17DF329D24C87D3500BCE2E3 /* Tests_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF329C24C87D3500BCE2E3 /* Tests_iOS.swift */; };
17DF32A824C87D3500BCE2E3 /* Tests_macOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF32A724C87D3500BCE2E3 /* Tests_macOS.swift */; }; 17DF32A824C87D3500BCE2E3 /* Tests_macOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF32A724C87D3500BCE2E3 /* Tests_macOS.swift */; };
17DF32AA24C87D3500BCE2E3 /* WriteFreely_MultiPlatformApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF328124C87D3300BCE2E3 /* WriteFreely_MultiPlatformApp.swift */; }; 17DF32AA24C87D3500BCE2E3 /* WriteFreely_MultiPlatformApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF328124C87D3300BCE2E3 /* WriteFreely_MultiPlatformApp.swift */; };
@ -165,7 +164,6 @@
17D4F36B2514EE2F00517CE6 /* LoraGX.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = LoraGX.ttf; sourceTree = "<group>"; }; 17D4F36B2514EE2F00517CE6 /* LoraGX.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = LoraGX.ttf; sourceTree = "<group>"; };
17D4F39D2514F0E500517CE6 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OpenSans-Regular.ttf"; sourceTree = "<group>"; }; 17D4F39D2514F0E500517CE6 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "OpenSans-Regular.ttf"; sourceTree = "<group>"; };
17D4F3A42514F1E900517CE6 /* Hack-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Hack-Regular.ttf"; sourceTree = "<group>"; }; 17D4F3A42514F1E900517CE6 /* Hack-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Hack-Regular.ttf"; sourceTree = "<group>"; };
17DB9C7C25A3582F0030ECC0 /* PostListBottomBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostListBottomBarView.swift; sourceTree = "<group>"; };
17DF328124C87D3300BCE2E3 /* WriteFreely_MultiPlatformApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WriteFreely_MultiPlatformApp.swift; sourceTree = "<group>"; }; 17DF328124C87D3300BCE2E3 /* WriteFreely_MultiPlatformApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WriteFreely_MultiPlatformApp.swift; sourceTree = "<group>"; };
17DF328224C87D3300BCE2E3 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; 17DF328224C87D3300BCE2E3 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
17DF328324C87D3500BCE2E3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 17DF328324C87D3500BCE2E3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@ -345,14 +343,6 @@
path = Resources; path = Resources;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
17DB9C7B25A358000030ECC0 /* PostList */ = {
isa = PBXGroup;
children = (
17DB9C7C25A3582F0030ECC0 /* PostListBottomBarView.swift */,
);
path = PostList;
sourceTree = "<group>";
};
17DF327B24C87D3300BCE2E3 = { 17DF327B24C87D3300BCE2E3 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -409,7 +399,6 @@
17B3E964250FAA9000EE9748 /* LaunchScreen.storyboard */, 17B3E964250FAA9000EE9748 /* LaunchScreen.storyboard */,
17681E3F251940F200D394AE /* Extensions */, 17681E3F251940F200D394AE /* Extensions */,
17A67CAB251A5D7E002F163D /* PostEditor */, 17A67CAB251A5D7E002F163D /* PostEditor */,
17DB9C7B25A358000030ECC0 /* PostList */,
17120DA624E19CE2002B9F6C /* Settings */, 17120DA624E19CE2002B9F6C /* Settings */,
); );
path = iOS; path = iOS;
@ -722,7 +711,6 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
17DB9C7D25A3582F0030ECC0 /* PostListBottomBarView.swift in Sources */,
17DF32AC24C87D3500BCE2E3 /* ContentView.swift in Sources */, 17DF32AC24C87D3500BCE2E3 /* ContentView.swift in Sources */,
173E19D1254318F600440F0F /* RemoteChangePromptView.swift in Sources */, 173E19D1254318F600440F0F /* RemoteChangePromptView.swift in Sources */,
17C42E622507D8E600072984 /* PostStatus.swift in Sources */, 17C42E622507D8E600072984 /* PostStatus.swift in Sources */,

View File

@ -1,53 +0,0 @@
import SwiftUI
struct PostListBottomBarView: View {
@EnvironmentObject var model: WriteFreelyModel
@Binding var postCount: Int
private var frameHeight: CGFloat {
var height: CGFloat = 50
let bottom = UIApplication.shared.windows.first?.safeAreaInsets.bottom ?? 0
height += bottom
return height
}
var body: some View {
VStack {
HStack(spacing: 0) {
Button(action: {
model.isPresentingSettingsView = true
}, label: {
Image(systemName: "gear")
})
Spacer()
Text(postCount == 1 ? "\(postCount) post" : "\(postCount) posts")
.foregroundColor(.secondary)
Spacer()
if model.isProcessingRequest {
ProgressView()
} else {
Button(action: {
DispatchQueue.main.async {
model.fetchUserCollections()
model.fetchUserPosts()
}
}, label: {
Image(systemName: "arrow.clockwise")
})
.disabled(!model.account.isLoggedIn)
}
}
.padding()
Spacer()
}
.frame(height: frameHeight)
.background(Color(UIColor.systemGray5))
.overlay(Divider(), alignment: .top)
}
}
struct PostListBottomBarView_Previews: PreviewProvider {
static var previews: some View {
PostListBottomBarView(postCount: .constant(0)).environmentObject(WriteFreelyModel())
}
}