Skip to content

Commit

Permalink
Add support for tab bars
Browse files Browse the repository at this point in the history
  • Loading branch information
imodeveloper committed May 16, 2024
1 parent c8482cb commit 8a417b0
Show file tree
Hide file tree
Showing 62 changed files with 87 additions and 26 deletions.
14 changes: 14 additions & 0 deletions DSKit/Sources/DSKit/Designable/DSAppearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ public extension DSAppearance {
]

UINavigationBar.appearance().standardAppearance = navigationBarAppearance

let itemAppearance = UITabBarItemAppearance()
itemAppearance.normal.iconColor = self.tabBar.unselectedItemTint
itemAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: self.tabBar.unselectedItemTint]
itemAppearance.selected.iconColor = self.tabBar.itemTint
itemAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: self.tabBar.itemTint]

let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithOpaqueBackground()
tabBarAppearance.backgroundColor = self.tabBar.barTint
tabBarAppearance.stackedLayoutAppearance = itemAppearance

UITabBar.appearance().standardAppearance = tabBarAppearance
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
}
}

Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/CartScreen4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extension CartScreen4 {
DSText("for").dsTextStyle(.subheadline)
DSText(itemsCount).dsTextStyle(.smallHeadline)
DSText("items").dsTextStyle(.subheadline)
DSPriceView(price: price, size: .subheadline)
DSPriceView(price: price, size: .headline)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/HomeScreen3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct HomeScreen3: View {

DSHScroll(data: viewModel.categories, id: \.self) { category in
CategoryView(title: category) { dismiss() }
}
}.dsPadding(.top, .small)

DSVStack {
DSSectionHeaderView(title: "Discounts", actionTitle: "View all", action: { self.dismiss() })
Expand Down
4 changes: 2 additions & 2 deletions DSKitExplorer/Screens/HomeScreen4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ struct HomeScreen4: View {
DSHScroll(data: viewModel.categories, id: \.id) { category in
CategoryView(category: category, isSelected: viewModel.selectedCategory == category.id)
.onTap { viewModel.selectedCategory = category.id }
}
}.dsPadding(.top, .small)

DSVStack {
DSGrid(viewHeight: 190, data: viewModel.products, id: \.id) { product in
ProductView(product: product).onTap { self.dismiss() }
}
}
}.dsPadding(.top, .small)
}
}.dsScreen()
}
Expand Down
4 changes: 2 additions & 2 deletions DSKitExplorer/Screens/ItemDetails2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ItemDetails2: View {
}
.safeAreaInset(edge: .bottom) {
DSBottomContainer {
DSButton(title: "Add to cart", rightSystemName: "cart") {
DSButton(title: "Add to cart", rightSystemName: "cart.fill") {
dismiss()
}
DSText(viewModel.priceDisclaimer, alignment: .center)
Expand Down Expand Up @@ -90,7 +90,7 @@ final class ItemDetails2Model: ObservableObject {
amount: "120.0",
regularAmount: "200",
currency: "$",
discountBadge: "80$ Off"
discountBadge: "80$ OFF"
)
}

Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/ItemDetails3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ final class ItemDetails3Model: ObservableObject {
amount: "120",
regularAmount: "200",
currency: "$",
discountBadge: "80$ Off"
discountBadge: "80$ OFF"
)
}

Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/ItemDetails4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ final class ItemDetails4Model: ObservableObject {
amount: "120.0",
regularAmount: "200",
currency: "$",
discountBadge: "80$ Off"
discountBadge: "80$ OFF"
)

@Published var selectedSize: String = "10"
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/ItemDetails5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ final class ItemDetails5Model: ObservableObject {
amount: "120",
regularAmount: "200",
currency: "$",
discountBadge: "80$ Off"
discountBadge: "80$ OFF"
)
}

Expand Down
1 change: 1 addition & 0 deletions DSKitExplorer/Screens/Items4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct Items4: View {
.dsTextStyle(.headline, 12)
.dsPadding(.horizontal, .large)
.dsCardStyle()
.dsHeight(.actionElement)
.onTap { self.dismiss() }
}
DSGrid(data: viewModel.products, id: \.id) { product in
Expand Down
1 change: 1 addition & 0 deletions DSKitExplorer/Screens/Items5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct Items5: View {
DSText(title).dsTextStyle(.smallHeadline)
.dsPadding(.horizontal)
.dsCardStyle()
.dsHeight(.actionElement)
.onTap { self.dismiss() }
}
DSGrid(data: viewModel.products, id: \.id) { product in
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/LogInScreen2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct LogInScreen2: View {

DSImageView(
systemName: "square.3.layers.3d.top.filled",
size: 50,
size: 70,
tint: .text(.headline)
)

Expand Down
17 changes: 11 additions & 6 deletions DSKitExplorer/Screens/LogInScreen3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct LogInScreen3: View {
DSVStack(alignment: .center, spacing: .medium) {
DSImageView(
systemName: "square.3.layers.3d.top.filled",
size: 60,
size: 90,
tint: .text(.headline)
)
DSText(
Expand All @@ -31,9 +31,9 @@ struct LogInScreen3: View {
.dsWidth(300)
}.frame(maxWidth: .infinity)

Spacer()
Spacer()
Spacer()
Spacer()
Spacer()
Spacer()

DSVStack(alignment: .center) {

Expand Down Expand Up @@ -61,10 +61,15 @@ struct LogInScreen3: View {

DSText("or sign up with Email").dsTextStyle(.subheadline)

DSButton(title: "Sign Up", rightSystemName: "envelope.fill", pushContentToSides: true, style: .light) {
DSButton(
title: "Sign Up",
rightSystemName: "envelope.fill",
pushContentToSides: true,
style: .light
) {
self.dismiss()
}

DSButton(title: "Log in with Email", style: .clear, action: {
self.dismiss()
})
Expand Down
31 changes: 26 additions & 5 deletions DSKitExplorer/Screens/NewsScreen1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ struct NewsScreen1: View {
var body: some View {
ScrollView {
DSVStack {
ForEach(viewModel.articles) { product in
ArticleView(article: product, style: $style)
ForEach(viewModel.articles) { article in
ArticleView(article: article, style: $style)
}
}
}
Expand Down Expand Up @@ -80,7 +80,6 @@ extension NewsScreen1 {
}
}.dsPadding()
} else {

DSHStack(alignment: .top, spacing: .medium) {

if let image = article.image {
Expand All @@ -100,7 +99,11 @@ extension NewsScreen1 {
}

if article.bookmarked {
DSImageView(systemName: "bookmark.fill", size: .font(.smallSubtitle), tint: .color(.orange))
DSImageView(
systemName: "bookmark.fill",
size: .font(.smallSubtitle),
tint: .color(.orange)
)
}

}.dsPadding()
Expand Down Expand Up @@ -203,7 +206,25 @@ struct Testable_NewsScreen1: View {

struct NewsScreen1_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance { Testable_NewsScreen1() }
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")
}
}
}
}
}

Expand Down
21 changes: 20 additions & 1 deletion DSKitExplorer/Screens/NewsScreen2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,26 @@ struct Testable_NewsScreen2: View {

struct NewsScreen2_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance { Testable_NewsScreen2() }
@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)
}
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions DSKitExplorerTests/AssertSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ extension XCTestCase {
let view = UIHostingController(rootView: testView)
view.overrideUserInterfaceStyle = .light

guard let window = UIApplication.shared.windows.first(where: { $0.isKeyWindow }) else {
fatalError("A key window is required for UI operations")
}
window.rootViewController = view
// guard let window = UIApplication.shared.windows.first(where: { $0.isKeyWindow }) else {
// fatalError("A key window is required for UI operations")
// }
//window.rootViewController = view

SnapshotTesting.assertSnapshot(
matching: view,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified DSKitTests/__Snapshots__/DSKitTests/DSRadioPickerView.1.png
Binary file modified DSKitTests/__Snapshots__/DSKitTests/DSSFSymbolButton.1.png

0 comments on commit 8a417b0

Please sign in to comment.