Skip to content

Commit

Permalink
fix(sdds-segment-element): fixed shape style
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirDimitraki committed Dec 27, 2024
1 parent 0ac9160 commit 9f364cb
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 139 deletions.
20 changes: 8 additions & 12 deletions SDDSComponents/SDDSComponents.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
69573D682D1D638600359D53 /* AppearanceConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69573D672D1D637D00359D53 /* AppearanceConfiguration.swift */; };
69573D6A2D1D756000359D53 /* SegmentElementAppearance+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69573D692D1D754400359D53 /* SegmentElementAppearance+Extensions.swift */; };
69573D6C2D1D7C5D00359D53 /* SegmentElementAppearance+Variation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69573D6B2D1D7C4300359D53 /* SegmentElementAppearance+Variation.swift */; };
6968433D2D1D934F002F8C7A /* SegmentElement+Exstensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6968433C2D1D9338002F8C7A /* SegmentElement+Exstensions.swift */; };
6968433F2D1DC003002F8C7A /* SegmentElementShapeStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6968433E2D1DBFF8002F8C7A /* SegmentElementShapeStyle.swift */; };
696843412D1E720B002F8C7A /* SegmentElement+ShapeStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 696843402D1E71FE002F8C7A /* SegmentElement+ShapeStyle.swift */; };
6969EADC2D1D5A74008536E5 /* SegmentElementColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6969EADB2D1D5A6C008536E5 /* SegmentElementColor.swift */; };
696843432D1EA12E002F8C7A /* SegmentElementAppearance+ButtonAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 696843422D1EA11A002F8C7A /* SegmentElementAppearance+ButtonAppearance.swift */; };
696843452D1EA35B002F8C7A /* SegmentElementAccessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 696843442D1EA348002F8C7A /* SegmentElementAccessibility.swift */; };
6969EADE2D1D5B8E008536E5 /* SegmentElementAppearanceVariations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6969EADD2D1D5B73008536E5 /* SegmentElementAppearanceVariations.swift */; };
6987445F2D1C367700559ABA /* SDDSCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6987445D2D1C367700559ABA /* SDDSCounter.swift */; };
698744602D1C367700559ABA /* CounterAppearance+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6987445A2D1C367700559ABA /* CounterAppearance+Extensions.swift */; };
Expand Down Expand Up @@ -168,10 +167,9 @@
69573D672D1D637D00359D53 /* AppearanceConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceConfiguration.swift; sourceTree = "<group>"; };
69573D692D1D754400359D53 /* SegmentElementAppearance+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SegmentElementAppearance+Extensions.swift"; sourceTree = "<group>"; };
69573D6B2D1D7C4300359D53 /* SegmentElementAppearance+Variation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SegmentElementAppearance+Variation.swift"; sourceTree = "<group>"; };
6968433C2D1D9338002F8C7A /* SegmentElement+Exstensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SegmentElement+Exstensions.swift"; sourceTree = "<group>"; };
6968433E2D1DBFF8002F8C7A /* SegmentElementShapeStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentElementShapeStyle.swift; sourceTree = "<group>"; };
696843402D1E71FE002F8C7A /* SegmentElement+ShapeStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SegmentElement+ShapeStyle.swift"; sourceTree = "<group>"; };
6969EADB2D1D5A6C008536E5 /* SegmentElementColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentElementColor.swift; sourceTree = "<group>"; };
696843422D1EA11A002F8C7A /* SegmentElementAppearance+ButtonAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SegmentElementAppearance+ButtonAppearance.swift"; sourceTree = "<group>"; };
696843442D1EA348002F8C7A /* SegmentElementAccessibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentElementAccessibility.swift; sourceTree = "<group>"; };
6969EADD2D1D5B73008536E5 /* SegmentElementAppearanceVariations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentElementAppearanceVariations.swift; sourceTree = "<group>"; };
698744562D1C367700559ABA /* CounterAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CounterAppearance.swift; sourceTree = "<group>"; };
698744572D1C367700559ABA /* CounterColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CounterColor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -361,13 +359,12 @@
6950A1262D1D4BE1001695C5 /* SegmentAppearance */ = {
isa = PBXGroup;
children = (
696843442D1EA348002F8C7A /* SegmentElementAccessibility.swift */,
696843422D1EA11A002F8C7A /* SegmentElementAppearance+ButtonAppearance.swift */,
696843402D1E71FE002F8C7A /* SegmentElement+ShapeStyle.swift */,
6968433E2D1DBFF8002F8C7A /* SegmentElementShapeStyle.swift */,
6968433C2D1D9338002F8C7A /* SegmentElement+Exstensions.swift */,
69573D6B2D1D7C4300359D53 /* SegmentElementAppearance+Variation.swift */,
69573D692D1D754400359D53 /* SegmentElementAppearance+Extensions.swift */,
6969EADD2D1D5B73008536E5 /* SegmentElementAppearanceVariations.swift */,
6969EADB2D1D5A6C008536E5 /* SegmentElementColor.swift */,
6950A1292D1D4D4E001695C5 /* SegmentElementSize.swift */,
6950A1272D1D4C28001695C5 /* SegmentElementAppearance.swift */,
);
Expand Down Expand Up @@ -1266,9 +1263,7 @@
81F753422CF505DE000156D9 /* IconButton+Extensions.swift in Sources */,
81F752E22CECD40A000156D9 /* BasicButton.swift in Sources */,
814E30412C99B090004601F7 /* Text+FillModifier.swift in Sources */,
6969EADC2D1D5A74008536E5 /* SegmentElementColor.swift in Sources */,
817339E62D033E650092608A /* RadioboxData.swift in Sources */,
6968433F2D1DC003002F8C7A /* SegmentElementShapeStyle.swift in Sources */,
816C62A22CB80EC400352891 /* Opacity.swift in Sources */,
814E30382C99AFB0004601F7 /* SDDSAvatarModifiers.swift in Sources */,
81D2B1992C32B3E400CAA7FD /* SDDSButton.swift in Sources */,
Expand All @@ -1290,6 +1285,7 @@
818C03C92C451424002C6D0A /* RadioboxAppearance.swift in Sources */,
8102BA312CBE9B3300C589D3 /* TextAreaAppearance.swift in Sources */,
8159F7302C5D1CFE00622836 /* FillStyle.swift in Sources */,
696843432D1EA12E002F8C7A /* SegmentElementAppearance+ButtonAppearance.swift in Sources */,
81F753242CF467E5000156D9 /* ButtonContentAlignment.swift in Sources */,
6969EADE2D1D5B8E008536E5 /* SegmentElementAppearanceVariations.swift in Sources */,
816AA9B02C97424000C3347C /* TextFieldSizeConfiguration.swift in Sources */,
Expand All @@ -1304,6 +1300,7 @@
81F7532E2CF4689C000156D9 /* ButtonAccessibility.swift in Sources */,
81685C2B2CFF898D00278446 /* SwitchAppearance+Extensions.swift in Sources */,
818C03B92C43B99B002C6D0A /* ColorToken+Extensions.swift in Sources */,
696843452D1EA35B002F8C7A /* SegmentElementAccessibility.swift in Sources */,
817339E92D033E8E0092608A /* AvatarAppearance.swift in Sources */,
6950A1282D1D4C47001695C5 /* SegmentElementAppearance.swift in Sources */,
811DE1712C5783B6000DD354 /* HierarchicalList.swift in Sources */,
Expand All @@ -1320,7 +1317,6 @@
81733A2B2D072FB70092608A /* AvatarAppearance+Extensions.swift in Sources */,
811DE15B2C5017FE000DD354 /* SDDSChipGroup.swift in Sources */,
81E9FA8F2C92B13E0041B5FF /* SDDSTextField.swift in Sources */,
6968433D2D1D934F002F8C7A /* SegmentElement+Exstensions.swift in Sources */,
8102BA3A2CBEAFB800C589D3 /* PlaceholderTextEditor.swift in Sources */,
818C03C72C45140B002C6D0A /* CheckboxAppearance.swift in Sources */,
814E30372C99AFAE004601F7 /* SDDSAvatarData.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
import Foundation
import SwiftUI

public struct SegmentElementSizeToButtonSizeConfigurationMapper: ButtonSizeConfiguration, SegmentElementSizeConfiguration {
public var height: CGFloat

public var cornerRadius: CGFloat

public var paddings: EdgeInsets

public var iconSize: CGSize

public var spinnerSize: CGSize = .zero

public var iconHorizontalGap: CGFloat

public var titleHorizontalGap: CGFloat

public var debugDescription: String {
"SizeExample"
}
}

public enum SegmentElementContentRight {
case icon(Image)
case subtitle(String)
Expand All @@ -38,16 +18,15 @@ public struct SDDSSegmentElement: View {
public let contentType: SegmentElementContent
public let isDisabled: Bool
public let appearance: SegmentElementAppearance
public let content: SegmentElementContentRight = .subtitle("")
public let accessibility: ButtonAccessibility // сделать SegmentElementAccessibility
public let accessibility: SegmentElementAccessibility
public var action: () -> Void

public init(
title: String,
contentType: SegmentElementContent,
isDisabled: Bool = false,
appearance: SegmentElementAppearance,
accessibility: ButtonAccessibility = ButtonAccessibility(),
accessibility: SegmentElementAccessibility = SegmentElementAccessibility() ,
action: @escaping () -> Void
) {
self.title = title
Expand Down Expand Up @@ -104,7 +83,7 @@ public struct SDDSSegmentElement: View {
spinnerImage: nil,
buttonStyle: .basic,
appearance: appearance.buttonAppearance,
accessibility: accessibility,
accessibility: accessibility.buttonAccessibility,
counter: nil,
action: action
)
Expand All @@ -118,7 +97,7 @@ public struct SDDSSegmentElement: View {
spinnerImage: nil,
buttonStyle: .basic,
appearance: appearance.buttonAppearance,
accessibility: accessibility,
accessibility: accessibility.buttonAccessibility,
counter: ViewProvider(counterData),
action: action
)
Expand All @@ -132,7 +111,7 @@ public struct SDDSSegmentElement: View {
spinnerImage: nil,
buttonStyle: .basic,
appearance: appearance.buttonAppearance,
accessibility: accessibility,
accessibility: accessibility.buttonAccessibility,
counter: nil,
action: action
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Foundation

public struct SegmentElementAccessibility {
public var label: String
public var hint: String
public var value: String

/**
Инициализатор для создания параметров доступности кнопки.

- Parameters:
- label: Метка доступности для кнопки.
- hint: Подсказка доступности для кнопки.
- value: Значение доступности для кнопки.
*/
public init(label: String, hint: String, value: String) {
self.label = label
self.hint = hint
self.value = value
}

/**
Инициализатор для создания параметров доступности кнопки с пустыми значениями.
*/
public init() {
self.label = ""
self.hint = ""
self.value = ""
}
}

extension SegmentElementAccessibility {
var buttonAccessibility: ButtonAccessibility {
ButtonAccessibility(
label: label,
hint: hint,
value: value
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation

extension SegmentElementAppearance {
var buttonAppearance: ButtonAppearance {
.init(
size: self.size,
shapeStyle: self.shapeStyle,
titleTypography: self.titleTypography,
titleColor: self.titleColor,
subtitleTypography: self.subtitleTypography,
subtitleColor: self.subtitleColor,
iconColor: self.iconColor,
spinnerColor: ButtonColor(),
backgroundColor: self.backgroundColor,
disabledAlpha: self.disabledAlpha,
loadingAlpha: 0
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public extension SegmentElementAppearance {
func applyColorVariation(variation: SegmentElementAppearance) -> SegmentElementAppearance {
SegmentElementAppearance(
size: size,
// shapeStyle: shapeStyle,
shapeStyle: shapeStyle,
titleTypography: titleTypography,
titleColor: variation.titleColor,
subtitleTypography: subtitleTypography,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,3 @@ public struct SegmentElementAppearance {
self.disabledAlpha = disabledAlpha
}
}

// в отдельный файл
extension SegmentElementAppearance {
var buttonAppearance: ButtonAppearance {
.init(
size: size,
shapeStyle: .default,
titleTypography: .default,
titleColor: ButtonColor(),
subtitleTypography: .default,
subtitleColor: ButtonColor(),
iconColor: ButtonColor(),
spinnerColor: ButtonColor(),
backgroundColor: ButtonColor(),
disabledAlpha: 0,
loadingAlpha: 0
)
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import SDDSServTheme

final class SegmentElementViewModel: ObservableObject {
@Published var title: String = ""
@Published var subtitle: String = ""
@Published var size: SegmentElementSizeConfiguration = SegmentElementSize.medium
@Published var contentType: SegmentElementContent = .none
@Published var iconAttributes: ButtonIconAttributes? = nil
@Published var isDisabled: Bool = false
@Published var appearance: SegmentElementAppearance = SDDSSegmentElement.default.appearance
// @Published var layoutMode: ButtonLayoutMode = .wrapContent
@Published var variationName: String = SDDSSegmentElement.clear.name

var cancellables: Set<AnyCancellable> = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ public extension SDDSSegmentElement {
name: "clear",
appearance: SegmentElementAppearance(
titleTypography: SDDSSegmentElement.titleTypography,
titleColor: SegmentElementColor(
titleColor: ButtonColor(
defaultColor: .textDefaultPrimary,
highlightedColor: .textDefaultPrimaryActive,
hoveredColor: .textDefaultPrimaryHover
),
subtitleTypography: SDDSSegmentElement.subtitleTypography,
subtitleColor: SegmentElementColor(
subtitleColor: ButtonColor(
defaultColor: .textDefaultSecondary,
highlightedColor: .textDefaultSecondaryActive,
hoveredColor: .textDefaultSecondaryHover
),
iconColor: SegmentElementColor(
iconColor: ButtonColor(
defaultColor: .textDefaultPrimary,
highlightedColor: .textDefaultPrimaryActive,
hoveredColor: .textDefaultPrimaryHover
),
backgroundColor: SegmentElementColor(
backgroundColor: ButtonColor(
defaultColor: .surfaceDefaultClear,
highlightedColor: .surfaceDefaultClearActive,
hoveredColor: .surfaceDefaultClearHover
Expand All @@ -51,23 +51,23 @@ public extension SDDSSegmentElement {
name: "default",
appearance: SegmentElementAppearance(
titleTypography: SDDSSegmentElement.titleTypography,
titleColor: SegmentElementColor(
titleColor: ButtonColor(
defaultColor: .textInversePrimary,
highlightedColor: .textInversePrimaryActive,
hoveredColor: .textInversePrimaryHover
),
subtitleTypography: SDDSSegmentElement.subtitleTypography,
subtitleColor: SegmentElementColor(
subtitleColor: ButtonColor(
defaultColor: .textDefaultSecondary,
highlightedColor: .textDefaultSecondaryActive,
hoveredColor: .textDefaultSecondaryHover
),
iconColor: SegmentElementColor(
iconColor: ButtonColor(
defaultColor: .textInversePrimary,
highlightedColor: .textInversePrimaryActive,
hoveredColor: .textInversePrimaryHover
),
backgroundColor: SegmentElementColor(
backgroundColor: ButtonColor(
defaultColor: .surfaceDefaultSolidDefault,
highlightedColor: .surfaceDefaultSolidDefaultActive,
hoveredColor: .surfaceDefaultSolidDefaultHover
Expand Down

0 comments on commit 9f364cb

Please sign in to comment.