Skip to content

Commit

Permalink
Added new sccreens and unit tetsts for them.
Browse files Browse the repository at this point in the history
Added new modifier full size views.
  • Loading branch information
Borinschi Ivan committed May 15, 2024
1 parent 1a499cb commit a1caf47
Show file tree
Hide file tree
Showing 33 changed files with 505 additions and 49 deletions.
34 changes: 34 additions & 0 deletions DSKit/Sources/DSKit/Modifiers/DSFrameModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// DSFrameModifier.swift
// DSKit
//
// Created by Ivan Borinschi on 19.12.2022.
//

import Foundation
import SwiftUI


public extension View {
func dsFullWidth(alignment: Alignment = .leading) -> some View {
self.frame(maxWidth: .infinity, alignment: alignment)
}
}

struct DSFullWidthModifier_Previews: PreviewProvider {
static var previews: some View {
DSPreviewForEachAppearance {
DSPreview {
DSText("Welcome to DSKit")
.dsFullWidth()
.border(Color.black, width: 1)
DSText("Welcome to DSKit")
.dsFullWidth(alignment: .center)
.border(Color.black, width: 1)
DSText("Welcome to DSKit")
.dsFullWidth(alignment: .trailing)
.border(Color.black, width: 1)
}
}
}
}
2 changes: 1 addition & 1 deletion DSKit/Sources/DSKit/Views/DSRadioPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public struct DSRadioPickerView<Data, ID, Content>: View where Data: RandomAcces
DSVStack(alignment: .leading) {
self.content(element, selected == element)
}
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
.overlay(alignment: .trailing) {
if selected == element {
DSImageView(systemName: "checkmark.circle.fill", size: 17, tint: .color(.green))
Expand Down
16 changes: 8 additions & 8 deletions DSKit/Sources/DSKit/Views/DSText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import SwiftUI
Initializes a `DSText` with the text content and optional alignment.
- Parameters:
- `text`: The text to be displayed.
- `multilineTextAlignment`: Alignment of the text within the view, defaulting to `.leading`.
- `alignment`: Alignment of the text within the view, defaulting to `.leading`.

#### Usage:
`DSText` is ideal for displaying any textual content where adherence to a design system is required. It supports multiple text styles and configurations, making it versatile for use in titles, body text, captions, and more.
Expand All @@ -29,18 +29,18 @@ public struct DSText: View {
@Environment(\.textStyle) var textStyle: DSTextStyle

let text: String
let multilineTextAlignment: TextAlignment
let alignment: TextAlignment

public init(_ text: String, multilineTextAlignment: TextAlignment = .leading) {
public init(_ text: String, alignment: TextAlignment = .leading) {
self.text = text
self.multilineTextAlignment = multilineTextAlignment
self.alignment = alignment
}

public var body: some View {
Text(text)
.font(textStyle.font(for: appearance))
.foregroundStyle(textStyle.color(for: appearance, and: viewStyle))
.multilineTextAlignment(multilineTextAlignment)
.multilineTextAlignment(alignment)
.dsDebuggable(debugColor: Color.orange.opacity(0.3))
}
}
Expand Down Expand Up @@ -156,18 +156,18 @@ struct Testable_DSText: View {
DSHStack {
DSText(
"Lorem Ipsum is simply dummy text.",
multilineTextAlignment: .center
alignment: .center
)
.dsTextStyle(.footnote)
.border(Color.black, width: 1)
DSText(
"Lorem Ipsum is simply dummy text.",
multilineTextAlignment: .leading
alignment: .leading
)
.dsTextStyle(.footnote)
.border(Color.black, width: 1)
DSText("Lorem Ipsum is simply dummy text.",
multilineTextAlignment: .trailing
alignment: .trailing
)
.dsTextStyle(.footnote)
.border(Color.black, width: 1)
Expand Down
18 changes: 16 additions & 2 deletions DSKitExplorer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
4185F9142BF38836007483AA /* NewsScreen1.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4185F9132BF38836007483AA /* NewsScreen1.swift */; };
4185F9162BF3D8C3007483AA /* NewsScreen2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4185F9152BF3D8C3007483AA /* NewsScreen2.swift */; };
4185F9182BF4C81A007483AA /* DSFrameModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4185F9172BF4C81A007483AA /* DSFrameModifier.swift */; };
41A858162BF340A400375D4D /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 41A858152BF340A400375D4D /* SnapshotTesting */; };
41A858182BF340AF00375D4D /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 41A858172BF340AF00375D4D /* SnapshotTesting */; };
41A8581D2BF3414A00375D4D /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 41A8581C2BF3414A00375D4D /* SDWebImageSwiftUI */; };
Expand Down Expand Up @@ -227,6 +230,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
4185F9132BF38836007483AA /* NewsScreen1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsScreen1.swift; sourceTree = "<group>"; };
4185F9152BF3D8C3007483AA /* NewsScreen2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NewsScreen2.swift; sourceTree = "<group>"; };
4185F9172BF4C81A007483AA /* DSFrameModifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSFrameModifier.swift; sourceTree = "<group>"; };
604EED482BD23BE9009E3278 /* DSKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DSKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
604EED4A2BD23BE9009E3278 /* DSKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSKit.h; sourceTree = "<group>"; };
604EED632BD23E1A009E3278 /* DSBackgroundModifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DSBackgroundModifier.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -453,6 +459,7 @@
604EED6B2BD23E1A009E3278 /* DSDebugLayoutModifier.swift */,
604EED6C2BD23E1A009E3278 /* DSDisplayShapeModifier.swift */,
604EED6D2BD23E1A009E3278 /* DSHeightModifier.swift */,
4185F9172BF4C81A007483AA /* DSFrameModifier.swift */,
604EED6E2BD23E1A009E3278 /* DSHideKeyboardWhenTappedModifier.swift */,
604EED6F2BD23E1A009E3278 /* DSKeyboardAwareModifier.swift */,
604EED702BD23E1A009E3278 /* DSMaxWidthCenteredModifier.swift */,
Expand Down Expand Up @@ -654,6 +661,8 @@
60D469982BCAF0DC00A6F7FC /* Items6.swift */,
60D469902BCAF0DC00A6F7FC /* Items7.swift */,
60D4699E2BCAF0DC00A6F7FC /* Items8.swift */,
4185F9132BF38836007483AA /* NewsScreen1.swift */,
4185F9152BF3D8C3007483AA /* NewsScreen2.swift */,
60D469B32BCAF0DC00A6F7FC /* LogInScreen1.swift */,
60D469A02BCAF0DC00A6F7FC /* LogInScreen2.swift */,
60D469AB2BCAF0DC00A6F7FC /* LogInScreen3.swift */,
Expand Down Expand Up @@ -912,6 +921,7 @@
604EEDFE2BD23E1B009E3278 /* BlueAppearance.swift in Sources */,
604EEE192BD23E1B009E3278 /* DSRatingView.swift in Sources */,
604EEDC72BD23E1B009E3278 /* DSBlurBackgroundModifier.swift in Sources */,
4185F9182BF4C81A007483AA /* DSFrameModifier.swift in Sources */,
604EEE062BD23E1B009E3278 /* DSText.swift in Sources */,
604EEDEA2BD23E1B009E3278 /* DSDynamicColor.swift in Sources */,
604EEDC62BD23E1B009E3278 /* DSBackgroundModifier.swift in Sources */,
Expand Down Expand Up @@ -1006,10 +1016,12 @@
60D469E02BCAF0DC00A6F7FC /* LogInScreen4.swift in Sources */,
60D469D52BCAF0DC00A6F7FC /* Filters1.swift in Sources */,
60D469E42BCAF0DC00A6F7FC /* SignUpScreen4.swift in Sources */,
4185F9142BF38836007483AA /* NewsScreen1.swift in Sources */,
60D469C62BCAF0DC00A6F7FC /* Items5.swift in Sources */,
60D469DD2BCAF0DC00A6F7FC /* CartScreen4.swift in Sources */,
60D469E32BCAF0DC00A6F7FC /* ItemDetails2.swift in Sources */,
60D469EB2BCAF0DC00A6F7FC /* SignUpScreen1.swift in Sources */,
4185F9162BF3D8C3007483AA /* NewsScreen2.swift in Sources */,
60D469CF2BCAF0DC00A6F7FC /* Items2.swift in Sources */,
60D469CC2BCAF0DC00A6F7FC /* Categories3.swift in Sources */,
60D469E22BCAF0DC00A6F7FC /* HomeScreen3.swift in Sources */,
Expand Down Expand Up @@ -1300,7 +1312,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"DSKitExplorer/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -1334,7 +1347,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"DSKitExplorer/Preview Content\"";
DEVELOPMENT_TEAM = "";
Expand Down
4 changes: 4 additions & 0 deletions DSKitExplorer/ScreenKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import Foundation

enum ScreenKey: String, CaseIterable, Identifiable {
case newsScreen1
case newsScreen2
case filters1
case filters2
case filters3
Expand Down Expand Up @@ -116,6 +118,8 @@ enum ScreenKey: String, CaseIterable, Identifiable {
case .logInScreen4: return "Log In Screen 4"
case .notificationsScreen1: return "Notifications Screen 1"
case .aboutUsScreen1: return "About us 1"
case .newsScreen1: return "News Screen 1"
case .newsScreen2: return "News Screen 2"
}
}
}
8 changes: 8 additions & 0 deletions DSKitExplorer/ScreenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ struct ScreenView: View {

var body: some View {
switch screen {
case .newsScreen1:
NewsScreen1()
.navigationTitle("News")
.environment(\.appearance, appearance)
case .newsScreen2:
NewsScreen2()
.navigationTitle("Bookmarks")
.environment(\.appearance, appearance)
case .cartScreen1:
CartScreen1()
.navigationTitle("My Cart")
Expand Down
6 changes: 3 additions & 3 deletions DSKitExplorer/Screens/AboutUsScreen1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ struct AboutUsScreen1: View {
DSVStack(alignment: .leading) {
DSHStack {
DSImageView(systemName: "message.fill", size: .font(.headline), tint: .text(.body))
DSText("DSFaker().text").dsTextStyle(.caption1).frame(maxWidth: .infinity, alignment: .leading)
DSText("DSFaker().text").dsTextStyle(.caption1).dsFullWidth()
}
DSDivider().background(appearance.secondaryView.separator.color)
DSHStack {
DSImageView(systemName: "shippingbox.fill", size: .font(.headline), tint: .text(.body))
DSText("DSFaker().text").dsTextStyle(.subheadline).frame(maxWidth: .infinity, alignment: .leading)
DSText("DSFaker().text").dsTextStyle(.subheadline).dsFullWidth()
}
DSDivider().background(appearance.secondaryView.separator.color)
DSHStack {
DSImageView(systemName: "leaf.arrow.triangle.circlepath", size: .font(.headline), tint: .text(.body))
DSText("DSFaker().text").dsTextStyle(.footnote).frame(maxWidth: .infinity, alignment: .leading)
DSText("DSFaker().text").dsTextStyle(.footnote).dsFullWidth()
}
}.dsCardStyle()
}
Expand Down
20 changes: 10 additions & 10 deletions DSKitExplorer/Screens/AboutUsScreen2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ struct AboutUsScreen2: View {
// DSVStack {
// DSVStack {
// DSText("Best Store in town", .font(.title2))
// .frame(maxWidth: .infinity, alignment: .leading)
// .dsFullWidth()
// DSText("Here you will feel the attitude, here you will receive quality, here you will see the atmosphere of an authentic store", .font(.body))
// .frame(maxWidth: .infinity, alignment: .leading)
// .dsFullWidth()
// }
//
// DSCoverFlow(height: 300, data: infoImageGallery, id: \.self) { image in
// DSImageView(url: image).dsCornerRadius()
// }
//
// DSVStack {
// DSText(DSFaker().text, .font(.body)).frame(maxWidth: .infinity, alignment: .leading)
// DSText(DSFaker().text, .font(.subheadline)).frame(maxWidth: .infinity, alignment: .leading)
// DSText(DSFaker().text, .font(.body)).frame(maxWidth: .infinity, alignment: .leading)
// DSText(DSFaker().text, .font(.body)).dsFullWidth()
// DSText(DSFaker().text, .font(.subheadline)).dsFullWidth()
// DSText(DSFaker().text, .font(.body)).dsFullWidth()
// }
// }
}
Expand All @@ -77,7 +77,7 @@ struct AboutUsScreen2: View {

DSVStack(spacing: .small) {
DSText("DSFaker().name").dsTextStyle(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
DSHStack {
DSImageView(systemName: "calendar", size: .size(14), tint: .text(.caption1))
DSText("14.05.2024").dsTextStyle(.subheadline)
Expand All @@ -90,7 +90,7 @@ struct AboutUsScreen2: View {
}
}
DSText("DSFaker().text").dsTextStyle(.caption1)
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
}
}
.dsPadding()
Expand Down Expand Up @@ -127,15 +127,15 @@ struct AboutUsScreen2: View {
.alignmentGuide(.healthSafetyAlignment) { d in d[VerticalAlignment.center] }
DSText("· Mask required\n· Temperature check required\n· Staff wear masks\n· Staff get temperature checks")
.dsTextStyle(.subheadline, 14)
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
}
}
.dsPadding()
.dsSecondaryBackground()
.dsCornerRadius()

Map(coordinateRegion: $region)
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
.dsHeight(200)
.dsCornerRadius()
.disabled(true)
Expand Down Expand Up @@ -172,7 +172,7 @@ struct ContactView: View {
DSText(title).dsTextStyle(.smallHeadline)
DSText(info)
.dsTextStyle(.subheadline, 14)
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
}
}.dsCardStyle()
}
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/CartScreen1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension CartScreen1 {
DSText(product.description).dsTextStyle(.smallSubtitle)
DSRatingView(rating: product.rating, size: 10)
DSPriceView(price: product.price, size: .smallHeadline).dsPadding(.top, .regular)
}.frame(maxWidth: .infinity, alignment: .leading)
}.dsFullWidth()


DSSFSymbolButton(name: "pencil.circle.fill", size: .mediumIcon)
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/CartScreen2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension CartScreen2 {
}
DSPriceView(price: product.price, size: .smallHeadline)
}
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
.overlay(alignment: .trailing, content: {
DSButton(
title: "Remove",
Expand Down
4 changes: 2 additions & 2 deletions DSKitExplorer/Screens/CartScreen3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ extension CartScreen3 {
.dsCornerRadius()
DSVStack(alignment: .leading) {
DSText(product.title).dsTextStyle(.smallHeadline)
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
DSText(product.description).dsTextStyle(.caption2)
DSPriceView(price: product.price, size: .smallHeadline)
}.frame(maxWidth: .infinity, alignment: .leading)
}.dsFullWidth()

DSSFSymbolButton(name: "minus.circle.fill", size: .mediumIcon)
.dsPadding(.trailing, .regular)
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/CartScreen4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension CartScreen4 {
DSText(product.size).dsTextStyle(.smallHeadline)
}
DSPriceView(price: product.price, size: .smallHeadline)
}.frame(maxWidth: .infinity, alignment: .leading)
}.dsFullWidth()

DSSFSymbolButton(name: "minus.circle.fill", size: .mediumIcon)
.dsPadding(.trailing, .regular)
Expand Down
4 changes: 2 additions & 2 deletions DSKitExplorer/Screens/CartScreen5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension CartScreen5 {
}
DSPriceView(price: product.price, size: .smallHeadline)

}.frame(maxWidth: .infinity, alignment: .leading)
}.dsFullWidth()

DSSFSymbolButton(name: "minus.circle.fill", size: .mediumIcon)
.dsPadding(.trailing, .regular)
Expand Down Expand Up @@ -138,7 +138,7 @@ extension CartScreen5 {
DSImageView(url: product.image, size: .size(width: 60, height: 40))
.dsCornerRadius()
DSVStack(alignment: .leading, spacing: .small) {
DSText(product.title, multilineTextAlignment: .leading)
DSText(product.title, alignment: .leading)
.dsTextStyle(.smallHeadline)
DSPriceView(price: product.price, size: .smallHeadline)
}
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/Categories1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension Categories1 {
}
}
.dsPadding(category.image != nil ? .zero : .medium)
.frame(maxWidth: .infinity, alignment: .leading)
.dsFullWidth()
}
.overlay(alignment: .trailing) {
DSChevronView().dsPadding()
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/ItemDetails1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct ItemDetails1: View {
DSButton(title: "Add to cart", rightSystemName: "cart.fill") {
dismiss()
}
DSText(viewModel.priceDisclaimer, multilineTextAlignment: .center)
DSText(viewModel.priceDisclaimer, alignment: .center)
.dsTextStyle(.caption2)
.dsPadding(.horizontal)
}
Expand Down
2 changes: 1 addition & 1 deletion DSKitExplorer/Screens/ItemDetails2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct ItemDetails2: View {
DSButton(title: "Add to cart", rightSystemName: "cart") {
dismiss()
}
DSText(viewModel.priceDisclaimer, multilineTextAlignment: .center)
DSText(viewModel.priceDisclaimer, alignment: .center)
.dsTextStyle(.caption2)
.dsPadding(.horizontal)
}
Expand Down
Loading

0 comments on commit a1caf47

Please sign in to comment.