Skip to content

Commit dc438ef

Browse files
committed
Release 10.0.0
Version 10.0.0
This version contains: New Features:
Added Dropdown menu component Improvements:
Improved the design and functionality of various components, including:
Card Accordion Dialog Tabs
1 parent e4b30b9 commit dc438ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1709
-631
lines changed

Sources/SirioKitIOS/Component/Accordion/Model/SirioAccordionData.swift

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,103 @@ import SwiftUI
1010
import UIKit
1111

1212
/// A representation of an accordion
13+
///
1314
/// - Parameters:
14-
/// - data: The structure of the component
15-
/// - content: The content inside accordion
16-
/// - isDisabled: Whether the accordion is disabled
17-
/// - isOpen: Whether the accordion is open
18-
/// - onTapAccordion: Callback that is executed when the accordion is tapped
19-
/// - accessibilityLabel: A string that identifies the accessibility element
20-
15+
/// - iconData: The icon to be displayed in the accordion.
16+
/// - title: The title of the accordion.
17+
/// - text: Additional text displayed alongside the title.
18+
/// - tag: A tag string used for display a tag component..
19+
/// - content: A view builder that provides the content inside the accordion.
20+
/// - isDisabled: Whether the accordion is disabled. Defaults to `false`.
21+
/// - isOpen: Whether the accordion is initially open. Defaults to `false`.
22+
/// - onTapAccordion: Callback executed when the accordion is tapped.
23+
/// - accessibilityLabel: A string for accessibility purposes.
2124
public class SirioAccordionData: Identifiable, ObservableObject {
2225

2326
public var id = UUID()
24-
private(set) var text: String
27+
private(set) var iconData: SirioIconData?
28+
private(set) var title: String
29+
private(set) var text: String?
30+
private(set) var tag: String?
2531
private(set) var content: AnyView
2632
@Published public var isDisabled: Bool
27-
@Published public var isOpen: Bool
33+
@Published public var isOpen: Bool
2834
private(set) var onTapAccordion: ((Bool) -> Void)?
2935
private(set) var accessibilityLabel: String?
30-
31-
public init<Content>(text: String,
36+
37+
// Default
38+
public init<Content>(title: String,
39+
@ViewBuilder content: @escaping () -> Content,
40+
isDisabled: Bool = false,
41+
isOpen: Bool = false,
42+
onTapAccordion: ((Bool) -> Void)? = nil,
43+
accessibilityLabel: String? = nil) where Content: View {
44+
self.iconData = nil
45+
self.title = title
46+
self.text = nil
47+
self.tag = nil
48+
self.content = AnyView(content())
49+
self.isDisabled = isDisabled
50+
self.isOpen = isOpen
51+
self.onTapAccordion = onTapAccordion
52+
self.accessibilityLabel = accessibilityLabel
53+
}
54+
55+
// Accordion with text
56+
public init<Content>(title: String,
57+
text: String,
3258
@ViewBuilder content: @escaping () -> Content,
3359
isDisabled: Bool = false,
3460
isOpen: Bool = false,
3561
onTapAccordion: ((Bool) -> Void)? = nil,
3662
accessibilityLabel: String? = nil) where Content: View {
63+
self.iconData = nil
64+
self.title = title
3765
self.text = text
66+
self.tag = nil
67+
self.content = AnyView(content())
68+
self.isDisabled = isDisabled
69+
self.isOpen = isOpen
70+
self.onTapAccordion = onTapAccordion
71+
self.accessibilityLabel = accessibilityLabel
72+
}
73+
74+
// Accordion with tag
75+
public init<Content>(title: String,
76+
tag: String,
77+
@ViewBuilder content: @escaping () -> Content,
78+
isDisabled: Bool = false,
79+
isOpen: Bool = false,
80+
onTapAccordion: ((Bool) -> Void)? = nil,
81+
accessibilityLabel: String? = nil) where Content: View {
82+
self.iconData = nil
83+
self.title = title
84+
self.text = nil
85+
self.tag = tag
86+
self.content = AnyView(content())
87+
self.isDisabled = isDisabled
88+
self.isOpen = isOpen
89+
self.onTapAccordion = onTapAccordion
90+
self.accessibilityLabel = accessibilityLabel
91+
}
92+
93+
// Accordion with icon
94+
public init<Content>(iconData: SirioIconData,
95+
title: String,
96+
@ViewBuilder content: @escaping () -> Content,
97+
isDisabled: Bool = false,
98+
isOpen: Bool = false,
99+
onTapAccordion: ((Bool) -> Void)? = nil,
100+
accessibilityLabel: String? = nil) where Content: View {
101+
self.iconData = iconData
102+
self.title = title
103+
self.text = nil
104+
self.tag = nil
38105
self.content = AnyView(content())
39106
self.isDisabled = isDisabled
40107
self.isOpen = isOpen
41108
self.onTapAccordion = onTapAccordion
42109
self.accessibilityLabel = accessibilityLabel
43110
}
111+
44112
}

Sources/SirioKitIOS/Component/Accordion/Style/SirioAccordionStyle.swift

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,53 @@ import SwiftUI
1111
// A struct that defines the style for Accordion component
1212
struct SirioAccordionStyle: ButtonStyle {
1313
@Environment(\.colorScheme) var colorScheme
14-
var text: String
14+
var iconData: SirioIconData?
15+
var title: String
16+
var text: String?
17+
var tag: String?
1518
var isOpen: Bool
1619
@Binding var isDisabled: Bool
1720
var withBorder: Bool = true
18-
@State var isHover = false
1921

2022
func makeBody(configuration: Self.Configuration) -> some View {
2123
VStack {
22-
HStack {
23-
SirioText(text: text, typography: Typography.Accordion.style)
24+
HStack(spacing: Size.s0) {
25+
if let iconData = iconData {
26+
SirioIcon(data: iconData)
27+
.frame(width: Size.Accordion.Icon.frame,
28+
height: Size.Accordion.Icon.frame)
29+
.foregroundColor(iconColor)
30+
.padding(.trailing, Size.p16)
31+
32+
}
33+
SirioText(text: title, typography: Typography.Accordion.title)
2434
.foregroundColor(textColor)
2535
.lineLimit(2)
36+
.if(text == nil || tag == nil) { view in
37+
view.padding(.trailing, Size.p24)
38+
}
2639

2740
Spacer()
2841

42+
if let tag = tag, !tag.isEmpty {
43+
SirioTag(type: .white, text: tag)
44+
.padding(.horizontal, Size.p12)
45+
} else if let text = text, !text.isEmpty {
46+
SirioText(text: text, typography: Typography.Accordion.text)
47+
.foregroundColor(textColor)
48+
.padding(.horizontal, Size.p12)
49+
}
50+
2951
SirioIcon(data: .init(icon: isOpen ? .angleUp : .angleDown))
30-
.frame(width: Size.Accordion.Icon.frame,
31-
height: Size.Accordion.Icon.frame)
52+
.frame(width: Size.Accordion.Arrow.frame,
53+
height: Size.Accordion.Arrow.frame)
3254
.foregroundColor(iconColor)
3355
}
3456
.frame(height: Size.Accordion.sectionHeight)
35-
.padding(.horizontal, Size.Accordion.paddingHorizontal)
57+
.padding(.horizontal, Size.p16)
3658
.border(borderColor, width: Size.Accordion.borderWidth)
3759
}
3860
.background(backgroundColor)
39-
.onHover { isHover in
40-
self.isHover = isHover
41-
}
4261
}
4362

4463
private var borderColor: Color {
@@ -49,16 +68,15 @@ struct SirioAccordionStyle: ButtonStyle {
4968
}
5069

5170
private var backgroundColor: Color {
52-
let hoverColor: Color = colorScheme == .dark ? Color.Accordion.Background.Hover.dark : Color.Accordion.Background.Hover.light
5371
let defaultColor: Color = colorScheme == .dark ? Color.Accordion.Background.Default.dark : Color.Accordion.Background.Default.light
5472
let activeColor: Color = colorScheme == .dark ? Color.Accordion.Background.Active.dark : Color.Accordion.Background.Active.light
5573

5674
if isDisabled {
5775
return Color.Accordion.Background.disabled
5876
} else if isOpen {
59-
return isHover ? hoverColor : activeColor
77+
return activeColor
6078
} else {
61-
return isHover ? hoverColor : defaultColor
79+
return defaultColor
6280
}
6381
}
6482

@@ -79,3 +97,47 @@ struct SirioAccordionStyle: ButtonStyle {
7997
}
8098
}
8199
}
100+
101+
#Preview {
102+
VStack {
103+
SirioBaseAccordion(data: .init(title: "Accordion Item #1", content: {
104+
SirioText(text: .loremIpsum, typography: .label_md_700)
105+
}, onTapAccordion: { isOpen in
106+
107+
}))
108+
109+
110+
// Icon
111+
SirioBaseAccordion(data: .init(iconData: SirioIconData(icon: .cube),
112+
title: "Accordion Item #1",
113+
content: {
114+
SirioText(text: .loremIpsum, typography: .label_md_700)
115+
}, onTapAccordion: { isOpen in
116+
117+
}))
118+
119+
// Tag
120+
SirioBaseAccordion(data: .init(title: "Accordion Item #1",
121+
tag: "Tag",
122+
content: {
123+
SirioText(text: .loremIpsum, typography: .label_md_700)
124+
}, onTapAccordion: { isOpen in
125+
126+
}))
127+
128+
// Text
129+
SirioBaseAccordion(data: .init(title: "Accordion Item #1", text: "Text", content: {
130+
SirioText(text: .loremIpsum, typography: .label_md_700)
131+
}, onTapAccordion: { isOpen in
132+
133+
}))
134+
135+
SirioBaseAccordion(data: .init(title: "Accordion Item con testo molto molto molto molto molto molto molto molto molto molto molto molto lungo ", content: {
136+
SirioText(text: "Lorem ipsum", typography: .label_md_700)
137+
.foregroundColor(.black)
138+
139+
}))
140+
141+
Spacer()
142+
}
143+
}

Sources/SirioKitIOS/Component/Accordion/View/SirioAccordion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public struct SirioAccordion: View {
2828
}
2929

3030
#Preview {
31-
SirioAccordion(data: .init(text: "Accordion Item #1", content: {
31+
SirioAccordion(data: .init(title: "Accordion Item #1", content: {
3232
SirioText(text: .loremIpsum, typography: .label_md_700)
3333
.foregroundColor(.black)
3434
}))

Sources/SirioKitIOS/Component/Accordion/View/SirioAccordionGroup.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ extension SirioAccordionGroup {
5050
#Preview {
5151
VStack {
5252
SirioAccordionGroup(data: [
53-
.init(text: "Accordion #1", content: {
53+
.init(title: "Accordion #1", content: {
5454
SirioText(text: .loremIpsum, typography: .label_md_700)
5555
.foregroundColor(.black)
5656
}),
57-
.init(text: "Accordion #2", content: {
57+
.init(title: "Accordion #2", content: {
5858
SirioText(text: .loremIpsum, typography: .label_md_700)
5959
.foregroundColor(.black)
6060
}),
61-
.init(text: "Accordion #3", content: {
61+
.init(title: "Accordion #3", content: {
6262
SirioText(text: .loremIpsum, typography: .label_md_700)
6363
.foregroundColor(.black)
6464
}, isDisabled: true)

Sources/SirioKitIOS/Component/Accordion/View/SirioBaseAccordion.swift

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,21 @@ struct SirioBaseAccordion: View {
3636
}
3737
}, label: {
3838
// Inside style
39-
}).buttonStyle(SirioAccordionStyle(text: data.text,
40-
isOpen: data.isOpen,
41-
isDisabled: $data.isDisabled,
42-
withBorder: withBorder))
39+
}).buttonStyle(SirioAccordionStyle(iconData: data.iconData,
40+
title: data.title,
41+
text: data.text,
42+
tag: data.tag,
43+
isOpen: data.isOpen,
44+
isDisabled: $data.isDisabled,
45+
withBorder: withBorder))
4346
.setAccessibilityLabel(data.accessibilityLabel)
4447

4548
if data.isOpen {
4649
self.data.content
4750
.frame(
4851
minWidth: 0,
4952
maxWidth: .infinity)
50-
.padding(Size.Accordion.paddingContent)
53+
.padding(Size.p16)
5154
.border(Color.Accordion.Border.content, width: 1)
5255
.background(Color.white)
5356
}
@@ -57,15 +60,44 @@ struct SirioBaseAccordion: View {
5760

5861
#Preview {
5962
VStack {
60-
SirioBaseAccordion(data: .init(text: "Accordion Item #1", content: {
61-
SirioText(text: .loremIpsum, typography: .label_md_700)
63+
SirioBaseAccordion(data: .init(title: "Accordion Item #1", content: {
64+
SirioText(text: .loremIpsum, typography: .bodyMdRegular)
65+
.foregroundStyle(Color.aliasTextColorSecondaryDark100)
6266
}, onTapAccordion: { isOpen in
6367

6468
}))
6569

66-
SirioBaseAccordion(data: .init(text: "Accordion Item con testo molto molto molto molto molto molto molto molto molto molto molto molto lungo ", content: {
67-
SirioText(text: "Lorem ipsum", typography: .label_md_700)
68-
.foregroundColor(.black)
70+
// Icon
71+
SirioBaseAccordion(data: .init(iconData: SirioIconData(icon: .cube),
72+
title: "Accordion Item #1",
73+
content: {
74+
SirioText(text: .loremIpsum, typography: .bodyMdRegular)
75+
.foregroundStyle(Color.aliasTextColorSecondaryDark100)
76+
}, isDisabled: true, onTapAccordion: { isOpen in
77+
78+
}))
79+
80+
// Tag
81+
SirioBaseAccordion(data: .init(title: "Accordion Item #1",
82+
tag: "Tag",
83+
content: {
84+
SirioText(text: .loremIpsum, typography: .bodyMdRegular)
85+
.foregroundStyle(Color.aliasTextColorSecondaryDark100)
86+
}, onTapAccordion: { isOpen in
87+
88+
}))
89+
90+
// Text
91+
SirioBaseAccordion(data: .init(title: "Accordion Item #1", text: "Text", content: {
92+
SirioText(text: .loremIpsum, typography: .bodyMdRegular)
93+
.foregroundStyle(Color.aliasTextColorSecondaryDark100)
94+
}, onTapAccordion: { isOpen in
95+
96+
}))
97+
98+
SirioBaseAccordion(data: .init(title: "Accordion Item con testo molto molto molto molto molto molto molto molto molto molto molto molto lungo ", content: {
99+
SirioText(text: "Lorem ipsum", typography: .bodyMdRegular)
100+
.foregroundStyle(Color.aliasTextColorSecondaryDark100)
69101

70102
}))
71103

Sources/SirioKitIOS/Component/Base/Model/ColorState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ import SwiftUI
1212
public struct ColorState {
1313
public var `default`: Color
1414
public var disabled: Color
15-
public var hover: Color
15+
public var hover: Color // Deprecated
1616
public var pressed: Color
1717
}

Sources/SirioKitIOS/Component/Base/View/SirioIcon.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public struct SirioIconData: Identifiable {
6060
public static let previewArrowLeft = SirioIconData(icon: .arrowLeft)
6161
public static let previewArrowRight = SirioIconData(icon: .arrowRight)
6262
public static let previewCube = SirioIconData(icon: .cube)
63+
public static let previewBookmark = SirioIconData(icon: .bookmark)
64+
public static let previewShare = SirioIconData(icon: .shareAlt)
6365
}
6466

6567
/// A basic component that represent an icon using the data

0 commit comments

Comments
 (0)