Skip to content

Commit

Permalink
feat: 🎸 [JIRA: HCPSDKFIORIUIKIT-2764] list picker enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyu0722 committed Oct 14, 2024
1 parent f44b1c5 commit 02f3d4a
Show file tree
Hide file tree
Showing 53 changed files with 3,593 additions and 97 deletions.
12 changes: 8 additions & 4 deletions Apps/Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
108E43D5292DAB7C006532F3 /* EmptyStateViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 108E43D4292DAB7C006532F3 /* EmptyStateViewExample.swift */; };
1F1A1FFA2C0BDA54007109D8 /* MenuSelectionExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1A1FF92C0BDA54007109D8 /* MenuSelectionExample.swift */; };
1F26DCFA261A5CD9006C43B1 /* FioriButtonContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F26DCF9261A5CD9006C43B1 /* FioriButtonContentView.swift */; };
1F3C92F125DF12C100A99A07 /* ListPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C92F025DF12C100A99A07 /* ListPicker.swift */; };
1F3C92F125DF12C100A99A07 /* _ListPickerExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C92F025DF12C100A99A07 /* _ListPickerExample.swift */; };
1F55FEF32AC941FF00D7A1BE /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F55FEF22AC941FF00D7A1BE /* View+Extensions.swift */; };
1F60179729A8439A00DBDCDE /* WatchExamplesApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F60179629A8439A00DBDCDE /* WatchExamplesApp.swift */; };
1F60179929A8439A00DBDCDE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F60179829A8439A00DBDCDE /* ContentView.swift */; };
Expand Down Expand Up @@ -114,6 +114,7 @@
B100639329C0624D00AF0CA2 /* StepProgressIndicatorExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = B100639229C0624D00AF0CA2 /* StepProgressIndicatorExample.swift */; };
B13408922B01FA0700600331 /* NavigationBarExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = B13408912B01FA0700600331 /* NavigationBarExample.swift */; };
B141D6BB29261F9E008A8BD6 /* SearchableListViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = B141D6BA29261F9E008A8BD6 /* SearchableListViewExample.swift */; };
B153E88E2CAA8EEA0017EB84 /* ListPickerItemExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = B153E88D2CAA8EE30017EB84 /* ListPickerItemExample.swift */; };
B18D2E9F2988B07B000A1821 /* KPIHeaderExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = B18D2E9E2988B07B000A1821 /* KPIHeaderExample.swift */; };
B18D593C2B0C52C700ABB1AD /* TabViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = B18D593B2B0C52C700ABB1AD /* TabViewExample.swift */; };
B190065A2C201BBE000C8B10 /* ProfileHeaderExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = B19006592C201BBE000C8B10 /* ProfileHeaderExample.swift */; };
Expand Down Expand Up @@ -224,7 +225,7 @@
108E43D4292DAB7C006532F3 /* EmptyStateViewExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyStateViewExample.swift; sourceTree = "<group>"; };
1F1A1FF92C0BDA54007109D8 /* MenuSelectionExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuSelectionExample.swift; sourceTree = "<group>"; };
1F26DCF9261A5CD9006C43B1 /* FioriButtonContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FioriButtonContentView.swift; sourceTree = "<group>"; };
1F3C92F025DF12C100A99A07 /* ListPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPicker.swift; sourceTree = "<group>"; };
1F3C92F025DF12C100A99A07 /* _ListPickerExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = _ListPickerExample.swift; sourceTree = "<group>"; };
1F55FEF22AC941FF00D7A1BE /* View+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Extensions.swift"; sourceTree = "<group>"; };
1F60179429A8439A00DBDCDE /* WatchExamples Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "WatchExamples Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1F60179629A8439A00DBDCDE /* WatchExamplesApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchExamplesApp.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -326,6 +327,7 @@
B100639229C0624D00AF0CA2 /* StepProgressIndicatorExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepProgressIndicatorExample.swift; sourceTree = "<group>"; };
B13408912B01FA0700600331 /* NavigationBarExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarExample.swift; sourceTree = "<group>"; };
B141D6BA29261F9E008A8BD6 /* SearchableListViewExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchableListViewExample.swift; sourceTree = "<group>"; };
B153E88D2CAA8EE30017EB84 /* ListPickerItemExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListPickerItemExample.swift; sourceTree = "<group>"; };
B18D2E9E2988B07B000A1821 /* KPIHeaderExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KPIHeaderExample.swift; sourceTree = "<group>"; };
B18D593B2B0C52C700ABB1AD /* TabViewExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabViewExample.swift; sourceTree = "<group>"; };
B19006592C201BBE000C8B10 /* ProfileHeaderExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileHeaderExample.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -425,8 +427,9 @@
1F3C92EF25DF12A100A99A07 /* FormCells */ = {
isa = PBXGroup;
children = (
B153E88D2CAA8EE30017EB84 /* ListPickerItemExample.swift */,
878219C32BEE128E002FDFBC /* StepperViewExample.swift */,
1F3C92F025DF12C100A99A07 /* ListPicker.swift */,
1F3C92F025DF12C100A99A07 /* _ListPickerExample.swift */,
B141D6BA29261F9E008A8BD6 /* SearchableListViewExample.swift */,
99193C842B719B8800F33BAF /* InformationViewExample.swift */,
64905D062C6D13E20062AAD4 /* SwitchExample.swift */,
Expand Down Expand Up @@ -1063,7 +1066,7 @@
99B6EF8C2672224D00515E8E /* UserConsentSample.swift in Sources */,
B84D24F02652F343007F2373 /* ObjectHeaderExample.swift in Sources */,
9996CD00262EB4E8001B99AE /* EULAViewSample.swift in Sources */,
1F3C92F125DF12C100A99A07 /* ListPicker.swift in Sources */,
1F3C92F125DF12C100A99A07 /* _ListPickerExample.swift in Sources */,
B1D41B20291A2D97004E64A5 /* DurationPickerExample.swift in Sources */,
1FC30414270541BF004BEE00 /* FioriThemeManagerContentView.swift in Sources */,
C106AD422B336EA400FE8B35 /* SearchWithSuggestion.swift in Sources */,
Expand Down Expand Up @@ -1123,6 +1126,7 @@
6D6E86712C53A0D500EDB6F4 /* CardViewWithTwoButtonsExample.swift in Sources */,
B8D4376F25F980340024EE7D /* ObjectCell_Spec_Jan2018.swift in Sources */,
8A5579CF24C1293C0098003A /* SettingsAxis.swift in Sources */,
B153E88E2CAA8EEA0017EB84 /* ListPickerItemExample.swift in Sources */,
B80DA9BC260BED9400C0B2E9 /* SingleActionCollectionView.swift in Sources */,
8732C2CB2C3524D9002110E9 /* CustomTimelineExample.swift in Sources */,
8A5579D924C1293C0098003A /* SettingsSelection.swift in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions Apps/Examples/Examples/FioriSwiftUICore/CoreContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ struct CoreContentView: View {
}

Section(header: Text("Pickers")) {
NavigationLink(
destination: _ListPickerItemExample())
{
Text("_ListPickerItem")
}

NavigationLink(
destination: ListPickerItemExample())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import FioriSwiftUICore
import SwiftUI

struct ListPickerItemExample: View {
private let model = ListPickerItemDataModel.data
private let stringsModel = ["First", "Second", "Third", "Fourth", "Fifth"]

@State var selections: Set<String> = []
@State var selection: String? = nil

@State var noneEmptySelection: String = "UIKit"

@State var axis: Axis = .horizontal
@State var useSimpleModel: Bool = false

@State var multiSelections: Bool = false
@State var isTrackingLiveChanges: Bool = false
@State var allowSearch: Bool = false
@State var customDestination: Bool = false
@State var disableEntriesSection: Bool = false
@State var allowEmpty: Bool = false

var body: some View {
List {
ListPickerItem(title: {
Text("Frameworks")
}, value: {
self.valueView
}, axis: self.axis,
destination: {
self.destinationView
.disableEntriesSection(self.disableEntriesSection)
.navigationTitle("Destination Title")
.ifApply(self.customDestination) {
$0.cancelActionStyle { _ in
Button {
print("This is dismiss without selections")
} label: {
Image(systemName: "chevron.left")
}
}
.applyActionStyle { _ in
Button {
print("This is dismiss with selections")
} label: {
Image(systemName: "checkmark")
}
}
.allEntriesSectionTitleStyle { _ in
Text("All Entries Title")
}
.selectedEntriesSectionTitleStyle { _ in
Text("Selected Entries Title")
}
.selectAllActionStyle { _ in
FioriButton(title: "Select All Action") { _ in }
}
.deselectAllActionStyle { _ in
FioriButton(title: "Deselect All Action") { _ in }
}
.listStyle(.plain)
}
})
.onChange(of: self.useSimpleModel) { _ in
self.selections.removeAll()
self.selection = nil
self.noneEmptySelection = self.useSimpleModel ? "First" : "UIKit"
}

Section("Pannel") {
Picker("Axis", selection: self.$axis) {
Text("Horizontal").tag(Axis.horizontal)
Text("Vertical").tag(Axis.vertical)
}

Toggle("Use simple model", isOn: self.$useSimpleModel)

Toggle("Multi Selections", isOn: self.$multiSelections)

Toggle("Tracking Live Changes", isOn: self.$isTrackingLiveChanges)

Toggle("Search Support", isOn: self.$allowSearch)

Toggle("Custom Destination", isOn: self.$customDestination)

Toggle("Disable Entries Section", isOn: self.$disableEntriesSection)

Toggle("Allow Empty", isOn: self.$allowEmpty)
}
}
}

@ViewBuilder var valueView: some View {
if self.multiSelections {
let str = Array(selections).joined(separator: ", ")
Text(str)
} else {
if self.allowEmpty {
Text(self.selection ?? "No Selection")
} else {
Text(self.noneEmptySelection)
}
}
}

@ViewBuilder var destinationView: some View {
if self.useSimpleModel {
let filter: (String, String) -> Bool = { f, s in f.contains(s) }
if self.multiSelections {
ListPickerDestination(self.stringsModel,
id: \.self,
selections: self.$selections,
allowEmpty: self.allowEmpty,
isTrackingLiveChanges: self.isTrackingLiveChanges,
searchFilter: self.allowSearch ? { f, s in f.contains(s) } : nil)
{ e in
Text(e)
}
} else {
if self.allowEmpty {
ListPickerDestination(self.stringsModel,
id: \.self,
selection: self.$selection,
isTrackingLiveChanges: self.isTrackingLiveChanges,
searchFilter: self.allowSearch ? filter : nil)
{ e in
Text(e)
}
} else {
ListPickerDestination(self.stringsModel,
id: \.self,
selection: self.$noneEmptySelection,
isTrackingLiveChanges: self.isTrackingLiveChanges,
searchFilter: self.allowSearch ? filter : nil)
{ e in
Text(e)
}
}
}
} else {
let filter: ((ListPickerItemDataModel.Framework, String) -> Bool) = { f, s in
if s.count > 0 {
return f.name.localizedCaseInsensitiveContains(s)
} else {
return true
}
}

if self.multiSelections {
ListPickerDestination(self.model,
id: \.name,
children: \.children,
selections: self.$selections,
allowEmpty: self.allowEmpty,
isTrackingLiveChanges: self.isTrackingLiveChanges,
searchFilter: self.allowSearch ? filter : nil)
{ e in
Text(e.name)
}
} else {
if self.allowEmpty {
ListPickerDestination(self.model,
id: \.name,
children: \.children,
selection: self.$selection,
isTrackingLiveChanges: self.isTrackingLiveChanges,
searchFilter: self.allowSearch ? filter : nil)
{ e in
Text(e.name)
}
} else {
ListPickerDestination(self.model,
id: \.name,
children: \.children,
selection: self.$noneEmptySelection,
isTrackingLiveChanges: self.isTrackingLiveChanges,
searchFilter: self.allowSearch ? filter : nil)
{ e in
Text(e.name)
}
}
}
}
}
}
Loading

0 comments on commit 02f3d4a

Please sign in to comment.