extract MainTabView
Start to clean ContentView up a bit. We need it to be cleaner before we introduce the SetupView Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
4C3AC79B28306D7B00E1F516 /* Contacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3AC79A28306D7B00E1F516 /* Contacts.swift */; };
|
||||
4C3AC79D2833036D00E1F516 /* FollowingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3AC79C2833036D00E1F516 /* FollowingView.swift */; };
|
||||
4C3AC79F2833115300E1F516 /* FollowButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3AC79E2833115300E1F516 /* FollowButtonView.swift */; };
|
||||
4C3AC7A12835A81400E1F516 /* SetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3AC7A02835A81400E1F516 /* SetupView.swift */; };
|
||||
4C3AC7A52836987600E1F516 /* MainTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3AC7A42836987600E1F516 /* MainTabView.swift */; };
|
||||
4C3BEFD22819DB9B00B3DE84 /* ProfileModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFD12819DB9B00B3DE84 /* ProfileModel.swift */; };
|
||||
4C3BEFD42819DE8F00B3DE84 /* NostrKind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFD32819DE8F00B3DE84 /* NostrKind.swift */; };
|
||||
4C3BEFD6281D995700B3DE84 /* ActionBarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BEFD5281D995700B3DE84 /* ActionBarModel.swift */; };
|
||||
@@ -121,6 +123,8 @@
|
||||
4C3AC79A28306D7B00E1F516 /* Contacts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Contacts.swift; sourceTree = "<group>"; };
|
||||
4C3AC79C2833036D00E1F516 /* FollowingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowingView.swift; sourceTree = "<group>"; };
|
||||
4C3AC79E2833115300E1F516 /* FollowButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FollowButtonView.swift; sourceTree = "<group>"; };
|
||||
4C3AC7A02835A81400E1F516 /* SetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupView.swift; sourceTree = "<group>"; };
|
||||
4C3AC7A42836987600E1F516 /* MainTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabView.swift; sourceTree = "<group>"; };
|
||||
4C3BEFD12819DB9B00B3DE84 /* ProfileModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileModel.swift; sourceTree = "<group>"; };
|
||||
4C3BEFD32819DE8F00B3DE84 /* NostrKind.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NostrKind.swift; sourceTree = "<group>"; };
|
||||
4C3BEFD5281D995700B3DE84 /* ActionBarModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBarModel.swift; sourceTree = "<group>"; };
|
||||
@@ -240,6 +244,8 @@
|
||||
4C363AA128296A7E006E126D /* SearchView.swift */,
|
||||
4C3AC79C2833036D00E1F516 /* FollowingView.swift */,
|
||||
4C3AC79E2833115300E1F516 /* FollowButtonView.swift */,
|
||||
4C3AC7A02835A81400E1F516 /* SetupView.swift */,
|
||||
4C3AC7A42836987600E1F516 /* MainTabView.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@@ -519,6 +525,7 @@
|
||||
4C3AC79F2833115300E1F516 /* FollowButtonView.swift in Sources */,
|
||||
4C3BEFD22819DB9B00B3DE84 /* ProfileModel.swift in Sources */,
|
||||
4C0A3F93280F66F5000448DE /* ReplyMap.swift in Sources */,
|
||||
4C3AC7A12835A81400E1F516 /* SetupView.swift in Sources */,
|
||||
4CACA9DC280C38C000D9BBE8 /* Profiles.swift in Sources */,
|
||||
4C363A94282704FA006E126D /* Post.swift in Sources */,
|
||||
4C363A8828236948006E126D /* BlocksView.swift in Sources */,
|
||||
@@ -545,6 +552,7 @@
|
||||
4C75EFB528049D790006080F /* Relay.swift in Sources */,
|
||||
4CEE2AF1280B216B00AB5EEF /* EventDetailView.swift in Sources */,
|
||||
4C75EFBB2804A34C0006080F /* ProofOfWork.swift in Sources */,
|
||||
4C3AC7A52836987600E1F516 /* MainTabView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -67,43 +67,8 @@ struct ContentView: View {
|
||||
|
||||
let sub_id = UUID().description
|
||||
let pubkey = MY_PUBKEY
|
||||
let privkey = MY_PRIVKEY
|
||||
let privkey = MY_PRIVKEY
|
||||
|
||||
var NotificationTab: some View {
|
||||
ZStack(alignment: .center) {
|
||||
TabButton(timeline: .notifications, img: "bell")
|
||||
|
||||
if new_notifications {
|
||||
Circle()
|
||||
.size(CGSize(width: 8, height: 8))
|
||||
.frame(width: 10, height: 10, alignment: .topTrailing)
|
||||
.alignmentGuide(VerticalAlignment.center) { a in a.height + 2.0 }
|
||||
.alignmentGuide(HorizontalAlignment.center) { a in a.width - 12.0 }
|
||||
.foregroundColor(.accentColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TabButton(timeline: Timeline, img: String) -> some View {
|
||||
Button(action: {switch_timeline(timeline)}) {
|
||||
Label("", systemImage: selected_timeline == timeline ? "\(img).fill" : img)
|
||||
.contentShape(Rectangle())
|
||||
.frame(maxWidth: .infinity, minHeight: 30.0)
|
||||
}
|
||||
.foregroundColor(selected_timeline != timeline ? .gray : .primary)
|
||||
}
|
||||
|
||||
var TabBar: some View {
|
||||
VStack {
|
||||
Divider()
|
||||
HStack {
|
||||
TabButton(timeline: .home, img: "house")
|
||||
NotificationTab
|
||||
TabButton(timeline: .global, img: "globe.americas")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var LoadingContainer: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
@@ -210,7 +175,7 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
|
||||
TabBar
|
||||
TabBar(new_notifications: $new_notifications, selected: $selected_timeline, action: switch_timeline)
|
||||
}
|
||||
.onAppear() {
|
||||
self.connect()
|
||||
|
||||
81
damus/Views/MainTabView.swift
Normal file
81
damus/Views/MainTabView.swift
Normal file
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// MainTabView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2022-05-19.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MainTabView: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
struct MainTabView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MainTabView()
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationsTab: View {
|
||||
@Binding var new_notifications: Bool
|
||||
@Binding var selected: Timeline?
|
||||
|
||||
let action: (Timeline) -> ()
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .center) {
|
||||
TabButton(timeline: .notifications, img: "bell", selected: $selected, action: action)
|
||||
|
||||
if new_notifications {
|
||||
Circle()
|
||||
.size(CGSize(width: 8, height: 8))
|
||||
.frame(width: 10, height: 10, alignment: .topTrailing)
|
||||
.alignmentGuide(VerticalAlignment.center) { a in a.height + 2.0 }
|
||||
.alignmentGuide(HorizontalAlignment.center) { a in a.width - 12.0 }
|
||||
.foregroundColor(.accentColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct TabButton: View {
|
||||
let timeline: Timeline
|
||||
let img: String
|
||||
|
||||
@Binding var selected: Timeline?
|
||||
|
||||
let action: (Timeline) -> ()
|
||||
|
||||
var body: some View {
|
||||
Button(action: {action(timeline)}) {
|
||||
Label("", systemImage: selected == timeline ? "\(img).fill" : img)
|
||||
.contentShape(Rectangle())
|
||||
.frame(maxWidth: .infinity, minHeight: 30.0)
|
||||
}
|
||||
.foregroundColor(selected != timeline ? .gray : .primary)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct TabBar: View {
|
||||
@Binding var new_notifications: Bool
|
||||
@Binding var selected: Timeline?
|
||||
|
||||
let action: (Timeline) -> ()
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Divider()
|
||||
HStack {
|
||||
TabButton(timeline: .home, img: "house", selected: $selected, action: action)
|
||||
NotificationsTab(new_notifications: $new_notifications, selected: $selected, action: action)
|
||||
TabButton(timeline: .global, img: "globe.americas", selected: $selected, action: action)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
damus/Views/SetupView.swift
Normal file
20
damus/Views/SetupView.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SetupView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2022-05-18.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SetupView: View {
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
struct SetupView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SetupView()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user