forked from SAP/cloud-sdk-ios-fiori
-
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.
- Loading branch information
Showing
199 changed files
with
7,753 additions
and
1,227 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
112 changes: 112 additions & 0 deletions
112
Apps/Examples/Examples/FioriSwiftUICore/AvatarStack/AvatarStackExample.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,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() | ||
} |
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
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
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
41 changes: 41 additions & 0 deletions
41
Apps/Examples/Examples/FioriSwiftUICore/FormCells/SwitchExample.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,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() | ||
} | ||
} |
Oops, something went wrong.