-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3,112 changed files
with
45,936 additions
and
1 deletion.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2022, INPS | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// swift-tools-version:5.6 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SirioKitIOS", | ||
platforms: [.iOS(.v15)], | ||
products: [ | ||
// Products define the executables and libraries a package produces, and make them visible to other packages. | ||
.library( | ||
name: "SirioKitIOS", | ||
targets: ["SirioKitIOS"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages this package depends on. | ||
.target( | ||
name: "SirioKitIOS", | ||
dependencies: [], | ||
resources: [.process("Fonts"), .process("Resources")] | ||
), | ||
.testTarget( | ||
name: "SirioKitIOSTests", | ||
dependencies: ["SirioKitIOS"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
# sirio-kit-iOS | ||
# Sirio-kit-iOS | ||
|
||
Sirio-kit-iOS is a library containing the iOS implementation of Sirio design system to be used for INPS mobile apps UI. | ||
|
||
## Requirements | ||
|
||
- iOS 15.0+ | ||
- Xcode 14+ | ||
- Swift 4+ | ||
|
||
|
||
## Usage | ||
1. Add the following to your Package.swift: | ||
```swift | ||
.package(url: "https://github.com/INPS-it/sirio-kit-iOS", .upToNextMajor(from: "4.0.0")) | ||
``` | ||
2. Declare `import SirioKitIOS` to use the components where you want use it. | ||
|
||
3. Register the font provided by the library in the app scene. (This example can be found in the demo project.) | ||
|
||
```swift | ||
@main | ||
struct iOS_ExampleApp: App { | ||
|
||
init() { | ||
// Register fonts from library | ||
Fonts.registerFonts() | ||
} | ||
} | ||
``` | ||
4. Use components as in the example app. | ||
|
||
## License | ||
|
||
SirioKitIOS is released under the BSD 3-Clause License [See LICENSE](https://github.com/INPS-it/SirioKitIOS/blob/main/LICENSE) for details. |
40 changes: 40 additions & 0 deletions
40
Sources/SirioKitIOS/Component/Accordion/Model/AccordionData.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// AccordionData.swift | ||
// | ||
// SPDX-FileCopyrightText: 2022 Istituto Nazionale Previdenza Sociale | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
import SwiftUI | ||
import UIKit | ||
|
||
/// A representation of an accordion | ||
/// - Parameters: | ||
/// - data: The structure of the component | ||
/// - content: The content inside accordion | ||
/// - isDisabled: Whether the accordion is disabled | ||
/// - isOpen: Whether the accordion is open | ||
/// - onTapAccordion: Callback that is executed when the accordion is tapped | ||
public class AccordionData: Identifiable, ObservableObject { | ||
|
||
public var id = UUID() | ||
private(set) var text: String | ||
private(set) var content: AnyView | ||
@Published public var isDisabled: Bool | ||
@Published public var isOpen: Bool | ||
private(set) var onTapAccordion: ((Bool) -> Void)? | ||
|
||
public init<Content>(text: String, | ||
@ViewBuilder content: @escaping () -> Content, | ||
isDisabled: Bool = false, | ||
isOpen: Bool = false, | ||
onTapAccordion: ((Bool) -> Void)? = nil) where Content: View { | ||
self.text = text | ||
self.content = AnyView(content()) | ||
self.isDisabled = isDisabled | ||
self.isOpen = isOpen | ||
self.onTapAccordion = onTapAccordion | ||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
Sources/SirioKitIOS/Component/Accordion/Style/AccordionStyle.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// AccordionStyle.swift | ||
// | ||
// SPDX-FileCopyrightText: 2022 Istituto Nazionale Previdenza Sociale | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
import SwiftUI | ||
|
||
// A struct to manage the Accordion style | ||
struct AccordionStyle: ButtonStyle { | ||
@Environment(\.colorScheme) var colorScheme | ||
var text: String | ||
var isOpen: Bool | ||
@Binding var isDisabled: Bool | ||
var withBorder: Bool = true | ||
@State var isHover = false | ||
|
||
func makeBody(configuration: Self.Configuration) -> some View { | ||
VStack { | ||
HStack { | ||
SirioText(text: text, typography: Typography.Accordion.style) | ||
.foregroundColor(textColor) | ||
.lineLimit(1) | ||
|
||
Spacer() | ||
|
||
SirioIcon(icon: isOpen ? .angleUp : .angleDown) | ||
.frame(width: Size.Accordion.Icon.frame, | ||
height: Size.Accordion.Icon.frame) | ||
.foregroundColor(iconColor) | ||
} | ||
.frame(height: Size.Accordion.sectionHeight) | ||
.padding(.horizontal, Size.Accordion.paddingHorizontal) | ||
.border(borderColor, width: Size.Accordion.borderWidth) | ||
} | ||
.background(backgroundColor) | ||
.onHover { isHover in | ||
self.isHover = isHover | ||
} | ||
} | ||
|
||
private var borderColor: Color { | ||
if withBorder { | ||
return colorScheme == .dark ? Color.Accordion.Border.dark : Color.Accordion.Border.light | ||
} | ||
return Color.clear | ||
} | ||
|
||
private var backgroundColor: Color { | ||
let hoverColor: Color = colorScheme == .dark ? Color.Accordion.Background.Hover.dark : Color.Accordion.Background.Hover.light | ||
let defaultColor: Color = colorScheme == .dark ? Color.Accordion.Background.Default.dark : Color.Accordion.Background.Default.light | ||
let activeColor: Color = colorScheme == .dark ? Color.Accordion.Background.Active.dark : Color.Accordion.Background.Active.light | ||
|
||
if isDisabled { | ||
return Color.Accordion.Background.disabled | ||
} else if isOpen { | ||
return isHover ? hoverColor : activeColor | ||
} else { | ||
return isHover ? hoverColor : defaultColor | ||
} | ||
} | ||
|
||
private var textColor: Color { | ||
if isDisabled { | ||
return Color.Accordion.Text.disabled | ||
} else { | ||
return colorScheme == .dark ? Color.Accordion.Text.dark : Color.Accordion.Text.light | ||
} | ||
|
||
} | ||
|
||
private var iconColor: Color { | ||
if isDisabled { | ||
return Color.Accordion.Icon.disabled | ||
} else { | ||
return colorScheme == .dark ? Color.Accordion.Icon.dark : Color.Accordion.Icon.light | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Sources/SirioKitIOS/Component/Accordion/View/Accordion.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Accordion.swift | ||
// | ||
// SPDX-FileCopyrightText: 2022 Istituto Nazionale Previdenza Sociale | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// Displays collapsible content panels for presenting information in a limited amount of space | ||
/// - Parameters: | ||
/// - data: The content of the component | ||
public struct Accordion: View { | ||
private var data: AccordionData | ||
|
||
public init(data: AccordionData) { | ||
self.data = data | ||
} | ||
|
||
public var body: some View { | ||
BaseAccordion(data: data) | ||
} | ||
} | ||
|
||
struct Accordion_Previews: PreviewProvider { | ||
static var previews: some View { | ||
Accordion(data: .init(text: "Accordion Item #1", content: { | ||
SirioText(text: .loremIpsum, typography: .label_md_700) | ||
.foregroundColor(.black) | ||
})) | ||
.colorScheme(.dark) | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
Sources/SirioKitIOS/Component/Accordion/View/AccordionGroup.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// AccordionGroup.swift | ||
// | ||
// SPDX-FileCopyrightText: 2022 Istituto Nazionale Previdenza Sociale | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// A group of accordions in column | ||
/// - Parameters: | ||
/// - data: A list of [AccordionData] each with the content of one accordion | ||
public struct AccordionGroup: View { | ||
@Environment(\.colorScheme) var colorScheme | ||
|
||
let data: [AccordionData] | ||
|
||
public init(data: [AccordionData]){ | ||
self.data = data | ||
} | ||
|
||
public var body: some View { | ||
VStack(spacing: 0) { | ||
ForEach(data.indices, id: \.self) { i in | ||
VStack(spacing: 0) { | ||
BaseAccordion(data: data[i], withBorder: false) | ||
|
||
if i < data.count - 1 { // The separator is shown only if it isn't the last item | ||
Rectangle() | ||
.fill(borderColor) | ||
.frame(height: Size.Accordion.borderWidth) | ||
} | ||
} | ||
} | ||
} | ||
.border(borderColor, width: Size.Accordion.borderWidth) | ||
} | ||
} | ||
|
||
extension AccordionGroup { | ||
var borderColor: Color { | ||
colorScheme == .dark ? Color.clear : Color.Accordion.Border.light | ||
} | ||
} | ||
|
||
struct AccordionGroup_Previews: PreviewProvider { | ||
|
||
static var previews: some View { | ||
VStack { | ||
AccordionGroup(data: [ | ||
.init(text: "Accordion #1", content: { | ||
SirioText(text: .loremIpsum, typography: .label_md_700) | ||
.foregroundColor(.black) | ||
}), | ||
.init(text: "Accordion #2", content: { | ||
SirioText(text: .loremIpsum, typography: .label_md_700) | ||
.foregroundColor(.black) | ||
}), | ||
.init(text: "Accordion #3", content: { | ||
SirioText(text: .loremIpsum, typography: .label_md_700) | ||
.foregroundColor(.black) | ||
}, isDisabled: true) | ||
]) | ||
Spacer() | ||
} | ||
} | ||
} |
Oops, something went wrong.