Skip to content

Commit

Permalink
Add home and news screens tabbars
Browse files Browse the repository at this point in the history
  • Loading branch information
imodeveloper committed May 20, 2024
1 parent 8a417b0 commit d7216c4
Show file tree
Hide file tree
Showing 60 changed files with 198 additions and 63 deletions.
16 changes: 8 additions & 8 deletions DSKitExplorer/ScreenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct ScreenView: View {
var body: some View {
switch screen {
case .newsScreen1:
NewsScreen1()
.navigationTitle("News")
Testable_NewsScreen1()
.environment(\.appearance, appearance)
.navigationBarHidden(true)
case .newsScreen2:
NewsScreen2()
.navigationTitle("Bookmarks")
Testable_NewsScreen2()
.environment(\.appearance, appearance)
.navigationBarHidden(true)
case .cartScreen1:
CartScreen1()
.navigationTitle("My Cart")
Expand Down Expand Up @@ -66,19 +66,19 @@ struct ScreenView: View {
.environment(\.appearance, appearance)
.navigationBarTitleDisplayMode(.inline)
case .homeScreen1:
HomeScreen1()
Testable_HomeScreen1()
.navigationBarHidden(true)
.environment(\.appearance, appearance)
case .homeScreen2:
HomeScreen2()
Testable_HomeScreen2()
.navigationBarHidden(true)
.environment(\.appearance, appearance)
case .homeScreen3:
HomeScreen3()
Testable_HomeScreen3()
.navigationBarHidden(true)
.environment(\.appearance, appearance)
case .homeScreen4:
HomeScreen4()
Testable_HomeScreen4()
.navigationBarHidden(true)
.environment(\.appearance, appearance)
case .profileScreen1:
Expand Down
31 changes: 29 additions & 2 deletions DSKitExplorer/Screens/HomeScreen1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,43 @@ final class HomeScreen1Model: ObservableObject {
// MARK: - Testable

struct Testable_HomeScreen1: View {
@Environment(\.dismiss) var dismiss
var body: some View {
HomeScreen1()
TabView {
HomeScreen1()
.tabItem {
Image(systemName: "house.fill")
Text("Home")
}
Text("Shop")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Shop")
}
Text("Cart")
.tabItem {
Image(systemName: "cart.fill")
Text("Cart")
}
DSVStack {
DSButton(title: "Dismiss", style: .clear) {
dismiss()
}
}.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}
}
}
}

// MARK: - Preview

struct HomeScreen1_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance { HomeScreen1() }
DSPreviewForEachAppearance {
Testable_HomeScreen1()
}
}
}

Expand Down
31 changes: 29 additions & 2 deletions DSKitExplorer/Screens/HomeScreen2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,43 @@ final class HomeScreen2Model: ObservableObject {
// MARK: - Testable

struct Testable_HomeScreen2: View {
@Environment(\.dismiss) var dismiss
var body: some View {
HomeScreen2()
TabView {
HomeScreen2()
.tabItem {
Image(systemName: "house.fill")
Text("Home")
}
Text("Shop")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Shop")
}
Text("Cart")
.tabItem {
Image(systemName: "cart.fill")
Text("Cart")
}
DSVStack {
DSButton(title: "Dismiss", style: .clear) {
dismiss()
}
}.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}
}
}
}

// MARK: - Preview

struct HomeScreen2_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance { HomeScreen2() }
DSPreviewForEachAppearance {
Testable_HomeScreen2()
}
}
}

Expand Down
31 changes: 29 additions & 2 deletions DSKitExplorer/Screens/HomeScreen3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,43 @@ final class HomeScreen3Model: ObservableObject {
// MARK: - Testable

struct Testable_HomeScreen3: View {
@Environment(\.dismiss) var dismiss
var body: some View {
HomeScreen3()
TabView {
HomeScreen3()
.tabItem {
Image(systemName: "house.fill")
Text("Home")
}
Text("Shop")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Shop")
}
Text("Cart")
.tabItem {
Image(systemName: "cart.fill")
Text("Cart")
}
DSVStack {
DSButton(title: "Dismiss", style: .clear) {
dismiss()
}
}.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}
}
}
}

// MARK: - Preview

struct HomeScreen3_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance { HomeScreen3() }
DSPreviewForEachAppearance {
Testable_HomeScreen3()
}
}
}

Expand Down
31 changes: 29 additions & 2 deletions DSKitExplorer/Screens/HomeScreen4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,43 @@ final class HomeScreen4Model: ObservableObject {
// MARK: - Testable

struct Testable_HomeScreen4: View {
@Environment(\.dismiss) var dismiss
var body: some View {
HomeScreen4()
TabView {
HomeScreen4()
.tabItem {
Image(systemName: "house.fill")
Text("Home")
}
Text("Shop")
.tabItem {
Image(systemName: "magnifyingglass")
Text("Shop")
}
Text("Cart")
.tabItem {
Image(systemName: "cart.fill")
Text("Cart")
}
DSVStack {
DSButton(title: "Dismiss", style: .clear) {
dismiss()
}
}.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}
}
}
}

// MARK: - Preview

struct HomeScreen4_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance { HomeScreen4() }
DSPreviewForEachAppearance {
Testable_HomeScreen4()
}
}
}

Expand Down
44 changes: 24 additions & 20 deletions DSKitExplorer/Screens/NewsScreen1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,30 @@ final class NewsScreen1Model {
// MARK: - Testable

struct Testable_NewsScreen1: View {
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationView {
NewsScreen1()
.navigationTitle("News")
TabView {
NavigationView {
NewsScreen1()
.navigationTitle("News")
}
.tabItem {
Image(systemName: "newspaper.fill")
Text("Home")
}
Text("Bookmarks")
.tabItem {
Image(systemName: "bookmark")
Text("Bookmarks")
}
DSVStack {
DSButton(title: "Dismiss", style: .clear) {
dismiss()
}.dsPadding()
}.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}
}
}
}
Expand All @@ -207,23 +227,7 @@ struct Testable_NewsScreen1: View {
struct NewsScreen1_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance {
TabView {
Testable_NewsScreen1()
.tabItem {
Image(systemName: "newspaper.fill")
Text("Home")
}
Text("Empty")
.tabItem {
Image(systemName: "bookmark")
Text("Bookmarks")
}
Text("Empty")
.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}
}
Testable_NewsScreen1()
}
}
}
Expand Down
47 changes: 26 additions & 21 deletions DSKitExplorer/Screens/NewsScreen2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,32 @@ final class NewsScreen2Model {
// MARK: - Testable

struct Testable_NewsScreen2: View {
@Environment(\.dismiss) var dismiss
@State var selectedTab: Int = 1
var body: some View {
NavigationView {
NewsScreen2()
.navigationTitle("Bookmarks")
TabView(selection: $selectedTab) {
Text("Home")
.tabItem {
Image(systemName: "newspaper.fill")
Text("Home")
}.tag(0)
NavigationView {
NewsScreen2()
.navigationTitle("Bookmarks")
}
.tabItem {
Image(systemName: "bookmark")
Text("Bookmarks")
}.tag(1)
DSVStack {
DSButton(title: "Dismiss", style: .clear) {
dismiss()
}.dsPadding()
}
.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}.tag(2)
}
}
}
Expand All @@ -159,25 +181,8 @@ struct Testable_NewsScreen2: View {

struct NewsScreen2_Previews: PreviewProvider {
static var previews: some View {
@State var selectedTab: Int = 1
DSPreviewForEachAppearance {
TabView(selection: $selectedTab) {
Text("Empty")
.tabItem {
Image(systemName: "newspaper.fill")
Text("Home")
}.tag(0)
Testable_NewsScreen2()
.tabItem {
Image(systemName: "bookmark")
Text("Bookmarks")
}.tag(1)
Text("Empty")
.tabItem {
Image(systemName: "gearshape")
Text("Settings")
}.tag(2)
}
Testable_NewsScreen2()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/ScreensView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct ScreensView: View {
}
}
}
.navigationTitle(appearance.title)
.navigationTitle("Screens")
.safeAreaInset(edge: .bottom) {
DSBottomContainer {
DSButton(title: "Change Appearance", action: { dismiss() })
Expand Down
Loading

0 comments on commit d7216c4

Please sign in to comment.