Skip to content

Commit

Permalink
Merge branch 'SAP:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dyongxu authored Sep 23, 2024
2 parents 6362262 + 98a0abb commit 478f020
Show file tree
Hide file tree
Showing 199 changed files with 7,753 additions and 1,227 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Create code coverage report
run: ./scripts/xccov-to-sonarqube-generic.sh /Users/runner/Library/Developer/Xcode/DerivedData/cloud-sdk-ios-fiori*/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml
- name: Store coverage for sonar job
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: coverage
path: sonarqube-generic-coverage.xml
Expand Down
53 changes: 44 additions & 9 deletions Apps/Examples/Examples.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import Combine
import FioriSwiftUICore
import FioriThemeManager
import Foundation
import SwiftUI

struct AvatarStackExample: View {
@StateObject var model = AvatarStackModel()

@ViewBuilder var avatarStack: some View {
AvatarStack {
ForEach(0 ..< self.model.avatarsCount, id: \.self) { _ in
Color.random
}
} avatarsTitle: {
if self.model.title.isEmpty {
EmptyView()
} else {
Text(self.model.title)
}
}
.avatarsLayout(self.model.avatarsLayout)
.isAvatarCircular(self.model.isCircular)
.avatarsTitlePosition(self.model.titlePosition)
.avatarsSpacing(self.model.spacing)
.avatarsMaxCount(self.model.maxCount)
.avatarsBorder(self.model.borderColor, width: self.model.borderWidth)
.avatarSize(self.avatarSize)
}

var avatarSize: CGSize? {
if let sideLength = model.sideLength {
CGSize(width: sideLength, height: sideLength)
} else {
nil
}
}

var body: some View {
List {
Section {
self.avatarStack
}

Picker("Avatar Count", selection: self.$model.avatarsCount) {
ForEach(0 ... 20, id: \.self) { number in
Text("\(number)").tag(number)
}
}
TextField("Enter Title", text: self.$model.title)
Toggle("isCircle", isOn: self.$model.isCircular)

Picker("Avatars Layout", selection: self.$model.avatarsLayout) {
Text("grouped").tag(AvatarStack.Layout.grouped)
Text("horizontal").tag(AvatarStack.Layout.horizontal)
}
Picker("Title Position", selection: self.$model.titlePosition) {
Text("leading").tag(AvatarStack.TextPosition.leading)
Text("trailing").tag(AvatarStack.TextPosition.trailing)
Text("top").tag(AvatarStack.TextPosition.top)
Text("bottom").tag(AvatarStack.TextPosition.bottom)
}

Picker("Spacing (only work for horizontal avatars)", selection: self.$model.spacing) {
ForEach([-4, -1, 0, 1, 4], id: \.self) { number in
Text("\(number)").tag(CGFloat(number))
}
}

Picker("Max Count", selection: self.$model.maxCount) {
Text("None").tag(nil as Int?)
ForEach([2, 4, 8], id: \.self) { number in
Text("\(number)").tag(number as Int?)
}
}

Picker("Side Length", selection: self.$model.sideLength) {
Text("Default").tag(nil as CGFloat?)
ForEach([10, 16, 20, 30, 40], id: \.self) { number in
Text("\(number)").tag(CGFloat(number) as CGFloat?)
}
}

Picker("Border Width", selection: self.$model.borderWidth) {
ForEach([0, 1, 2, 4], id: \.self) { number in
Text("\(number)").tag(CGFloat(number))
}
}

ColorPicker(selection: self.$model.borderColor, supportsOpacity: false) {
Text("Border Color")
}
}
}
}

class AvatarStackModel: ObservableObject {
@Published var avatarsCount: Int = 2
@Published var title: String = "This is a text for avatar stack."
@Published var isCircular: Bool = true
@Published var avatarsLayout: AvatarStack.Layout = .grouped
@Published var titlePosition: AvatarStack.TextPosition = .trailing
@Published var spacing: CGFloat = -1
@Published var maxCount: Int? = nil
@Published var sideLength: CGFloat? = nil
@Published var borderColor = Color.clear
@Published var borderWidth: CGFloat = 1
}

#Preview {
AvatarStackExample()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct MobileCardExample: View {
ForEach(0 ..< CardTests.cardSamples.count, id: \.self) { i in
CardTests.cardSamples[i]
}
.listRowBackground(Color.preferredColor(.primaryGroupedBackground))
}
.cardStyle(.card)
.listStyle(.plain)
Expand All @@ -26,6 +27,7 @@ struct MobileCardExample: View {
ForEach(0 ..< CardTests.cardFooterSamples.count, id: \.self) { i in
CardTests.cardFooterSamples[i]
}
.listRowBackground(Color.preferredColor(.primaryGroupedBackground))
}
.cardStyle(.card)
.listStyle(.plain)
Expand Down Expand Up @@ -77,6 +79,7 @@ struct MasonryTestView: View {
.cardStyle(.card)
}
.padding()
.background(Color.preferredColor(.primaryGroupedBackground))
}
}

Expand All @@ -90,12 +93,12 @@ struct CarouselTestView: View {
let defaultNumberOfColumns: Double

@State var isPresented: Bool = false
@State var isSameHeight: Bool = true
@State var isSnapping: Bool = true
@State var numberOfColumns: Double
@State var spacing = 16.0
@State var padding = 16.0
@State var alignment = 0
@State var contentType = 0

init(_ n: Double = 1) {
self.defaultNumberOfColumns = n
Expand All @@ -104,35 +107,18 @@ struct CarouselTestView: View {

var body: some View {
ScrollView(.vertical) {
Carousel(numberOfColumns: Int(self.numberOfColumns), spacing: self.spacing, alignment: self.alignment == 0 ? .top : (self.alignment == 1 ? .center : .bottom), isSnapping: self.isSnapping) {
if self.contentType == 0 {
ForEach(0 ..< CardTests.cardSamples.count, id: \.self) { i in
CardTests.cardSamples[i]
}
} else {
ForEach(0 ..< 20, id: \.self) { i in
Text("Text \(i)")
.font(.title)
.padding()
.frame(height: 100)
.background(Color.gray)
}
Carousel(numberOfColumns: Int(self.numberOfColumns), spacing: self.spacing, alignment: self.alignment == 0 ? .top : (self.alignment == 1 ? .center : .bottom), isSnapping: self.isSnapping, isSameHeight: self.isSameHeight) {
ForEach(0 ..< CardTests.cardSamples.count, id: \.self) { i in
CardTests.cardSamples[i]
}
}
.cardStyle(.card)
.padding(self.padding)
.border(Color.gray)
}
.background(Color.preferredColor(.primaryGroupedBackground))
.sheet(isPresented: self.$isPresented, content: {
VStack {
HStack {
Text("Content Type:")
Spacer()
Picker("Content Type", selection: self.$contentType) {
Text("Card").tag(0)
Text("Text").tag(1)
}
}
Toggle("Same card height", isOn: self.$isSameHeight)

HStack {
Text("numberOfColumns: \(Int(self.numberOfColumns))")
Expand All @@ -142,11 +128,6 @@ struct CarouselTestView: View {
Text("spacing: \(Int(self.spacing))")
Slider(value: self.$spacing, in: 0 ... 20, step: 4)
}
HStack {
Text("padding: \(Int(self.padding))")
Slider(value: self.$padding, in: 0 ... 20, step: 4)
}

HStack {
Text("Alignment:")
Spacer()
Expand All @@ -156,8 +137,14 @@ struct CarouselTestView: View {
Text("Bottom").tag(2)
}
}

Toggle("isSnapping", isOn: self.$isSnapping)

Divider()

HStack {
Text("Padding around Carousel: \(Int(self.padding))")
Slider(value: self.$padding, in: 0 ... 20, step: 4)
}
}
.padding()
.presentationDetents([.medium])
Expand Down
28 changes: 28 additions & 0 deletions Apps/Examples/Examples/FioriSwiftUICore/CoreContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ struct CoreContentView: View {
var body: some View {
List {
Section(header: Text("Views")) {
NavigationLink(
destination: AvatarStackExample(),
label: {
Text("AvatarStack")
}
)

NavigationLink(
destination: FioriButtonContentView(),
label: {
Expand Down Expand Up @@ -168,6 +175,13 @@ struct CoreContentView: View {
}
)

NavigationLink(
destination: SwitchExample(),
label: {
Text("Switch")
}
)

NavigationLink(
destination: StepProgressIndicatorExample())
{
Expand All @@ -193,6 +207,12 @@ struct CoreContentView: View {
{
Text("SegmentedControlPicker")
}

NavigationLink(
destination: DateTimePickerExample())
{
Text("DateTimePicker")
}
}

Section(header: Text("Onboarding")) {
Expand Down Expand Up @@ -247,6 +267,14 @@ struct CoreContentView: View {
}
}

Section(header: Text("Utilities")) {
NavigationLink(
destination: ShadowEffectExample())
{
Text("Shadow Effect")
}
}

Section(header: Text("ExperimentalContentView")) {
NavigationLink(
destination: ExperimentalContentView())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct StepperViewExample: View {
StepperView(
title: { Text("Value") },
text: self.$normalStepValue,
step: 1,
stepRange: 0 ... 100,
description: { Text("Hint Text") }
)
Expand All @@ -41,8 +40,7 @@ struct StepperViewExample: View {
StepperView(
title: { Text("Value") },
text: self.$negativeValue,
step: 1,
stepRange: 0 ... 100,
stepRange: 10 ... 100,
description: { Text(self.isInputValueValid ? "Hint Text" : "Validation failed.") }
).onChange(of: self.negativeValue, perform: { value in
if Int(value) ?? 1 > 80 {
Expand All @@ -55,7 +53,7 @@ struct StepperViewExample: View {
.disabled(self.isDisabled)

StepperView(
title: { Text("loooooooooooooooooooooongTitle") },
title: { Text("loooooooooooooooooooooooooooooooooooongTitle") },
text: self.$longTitleStepValue,
step: 3,
stepRange: 0 ... 100,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import FioriSwiftUICore
import Foundation
import SwiftUI

struct SwitchExample: View {
@State var v1: Bool = false
@State var v2: Bool = true
@State var v3: Bool = true

struct CustomTitleStyle: TitleStyle {
@Environment(\.isEnabled) var isEnabled
func makeBody(_ configuration: TitleConfiguration) -> some View {
Title(configuration)
.font(.fiori(forTextStyle: .title3))
.foregroundStyle(Color.preferredColor(self.isEnabled ? .indigo7 : .grey5))
}
}

struct CustomSwitchStyle: SwitchStyle {
func makeBody(_ configuration: SwitchConfiguration) -> some View {
Switch(configuration)
.tint(Color.preferredColor(.mango5))
}
}

var body: some View {
VStack {
SwitchView(title: "Switch", isOn: self.$v1)
SwitchView(title: "Disabled Switch", isOn: self.$v2).disabled(/*@START_MENU_TOKEN@*/true/*@END_MENU_TOKEN@*/)
SwitchView(title: "Custom Style", isOn: self.$v3)
.titleStyle(CustomTitleStyle())
.switchStyle(CustomSwitchStyle())
}
}
}

struct SwitchExample_Previews: PreviewProvider {
static var previews: some View {
SwitchExample()
}
}
Loading

0 comments on commit 478f020

Please sign in to comment.