Skip to content

Commit b719161

Browse files
leoxiao-sapdyongxu
andauthored
feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric (#1236)
* feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric add doc * feat: 🎸 [HCPSDKFIORIUIKIT-2957] Generic AlphaNumeric * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric - added phoneNumber and CustomNumber formatters * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric * feat: 🎸 [HCPSDKFIORIUIKIT-2957]Implement a generic AlphaNumeric --------- Co-authored-by: dyongxu <[email protected]>
1 parent 3a3a737 commit b719161

32 files changed

+1936
-35
lines changed

Apps/Examples/Examples.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
64905D092C7693970062AAD4 /* DateTimePickerExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64905D082C7693970062AAD4 /* DateTimePickerExample.swift */; };
4747
649C7F482CE531C8007B78A7 /* ProgressIndicatorExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 649C7F472CE531C5007B78A7 /* ProgressIndicatorExample.swift */; };
4848
64A3FF012D12527F00992B24 /* DimensionSelectorExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64A3FF002D12527B00992B24 /* DimensionSelectorExample.swift */; };
49+
684E21D32E4D7921001823E2 /* TextInputExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 684E21D22E4D7921001823E2 /* TextInputExample.swift */; };
4950
691DE21925F2A30B00094D4A /* KPIItemExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 691DE21825F2A30B00094D4A /* KPIItemExample.swift */; };
5051
692F338B26556A6A009B98DA /* SideBarExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 692F338A26556A6A009B98DA /* SideBarExample.swift */; };
5152
69B2B5D9268A333C009AC6B3 /* KPIProgressViewExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69B2B5D8268A333C009AC6B3 /* KPIProgressViewExample.swift */; };
@@ -320,6 +321,7 @@
320321
64905D082C7693970062AAD4 /* DateTimePickerExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTimePickerExample.swift; sourceTree = "<group>"; };
321322
649C7F472CE531C5007B78A7 /* ProgressIndicatorExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressIndicatorExample.swift; sourceTree = "<group>"; };
322323
64A3FF002D12527B00992B24 /* DimensionSelectorExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DimensionSelectorExample.swift; sourceTree = "<group>"; };
324+
684E21D22E4D7921001823E2 /* TextInputExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextInputExample.swift; sourceTree = "<group>"; };
323325
691DE21825F2A30B00094D4A /* KPIItemExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KPIItemExample.swift; sourceTree = "<group>"; };
324326
692F338A26556A6A009B98DA /* SideBarExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideBarExample.swift; sourceTree = "<group>"; };
325327
69B2B5D8268A333C009AC6B3 /* KPIProgressViewExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KPIProgressViewExample.swift; sourceTree = "<group>"; };
@@ -671,6 +673,14 @@
671673
path = AIUserFeedback;
672674
sourceTree = "<group>";
673675
};
676+
684E21D12E4D78D5001823E2 /* TextInput */ = {
677+
isa = PBXGroup;
678+
children = (
679+
684E21D22E4D7921001823E2 /* TextInputExample.swift */,
680+
);
681+
path = TextInput;
682+
sourceTree = "<group>";
683+
};
674684
691DE21725F2A2F000094D4A /* KPI */ = {
675685
isa = PBXGroup;
676686
children = (
@@ -846,6 +856,7 @@
846856
8A5579C824C1293C0098003A /* FioriSwiftUICore */ = {
847857
isa = PBXGroup;
848858
children = (
859+
684E21D12E4D78D5001823E2 /* TextInput */,
849860
5A80A5EE2DE706B700950E40 /* AIUserFeedback */,
850861
B163CD842DE54B9A00B011D8 /* WritingAssistant */,
851862
87F70A662DDB9EC700B683B4 /* BarcodeScanner */,
@@ -1524,6 +1535,7 @@
15241535
6D6E86252C50D42000EDB6F4 /* FioriButtonInListExample.swift in Sources */,
15251536
B8D4377125F983730024EE7D /* ObjectCell_Rules_Alignment.swift in Sources */,
15261537
A65FB3BF2DE464A000930093 /* CurrencyInputExample.swift in Sources */,
1538+
684E21D32E4D7921001823E2 /* TextInputExample.swift in Sources */,
15271539
8A5579D524C1293C0098003A /* SettingsSeries.swift in Sources */,
15281540
6432FFA02C5164F8008ECE89 /* SegmentedControlExample.swift in Sources */,
15291541
9DEC27B52C3F3DB30070B571 /* KeyValueItemExample.swift in Sources */,

Apps/Examples/Examples/FioriSwiftUICore/CoreContentView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct CoreContentView: View {
6161
MenuItem(title: "SectionHeader/Footer Example", section: "Headers", destination: SectionHeaderFooterExample()),
6262

6363
// Controls
64+
MenuItem(title: "Format Text Input", section: "Controls", destination: TextInputExample()),
6465
MenuItem(title: "Customized TabView", section: "Controls", destination: TabViewExample()),
6566
MenuItem(title: "Customized Toolbar", section: "Controls", destination: ToolbarExample()),
6667
MenuItem(title: "Dimension Selector", section: "Controls", destination: DimensionSelectorExample()),
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import FioriSwiftUICore
2+
import SwiftUI
3+
4+
struct TextInputExample: View {
5+
@State var showsCharCount = true
6+
@State var allowsBeyondLimit = true
7+
8+
@State private var phoneNumber: String = ""
9+
@State private var price: String = ""
10+
@State private var numeric: String = ""
11+
@State private var date: String = ""
12+
@State private var genericText: String = ""
13+
@State private var genericText2: String = ""
14+
15+
@State private var valueText: String = ""
16+
17+
// the below ids used to scroll to related items
18+
private var phoneNumberId = UUID()
19+
private var priceId = UUID()
20+
private var numericId = UUID()
21+
private var dateId = UUID()
22+
private var genericTextId = UUID()
23+
private var genericText2Id = UUID()
24+
private var valueTextId = UUID()
25+
26+
var body: some View {
27+
ScrollViewReader { _ in
28+
List {
29+
Section {
30+
TextFieldFormView(title: "Phone Number", text: self.$phoneNumber, formatter: self.phoneNumberFormatter, placeholder: "(123) 456-7890", errorMessage: AttributedString(""), maxTextLength: 13, hintText: AttributedString("(###) ###-####"), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit, isRequired: false, actionIcon: nil, action: nil)
31+
.id(self.phoneNumberId)
32+
} header: {
33+
Text("Phone Number Formatter - Text field form view")
34+
.font(.fiori(forTextStyle: .subheadline))
35+
.foregroundStyle(Color.preferredColor(.secondaryLabel))
36+
}
37+
Section {
38+
TextFieldFormView(title: "Price", text: self.$price, formatter: self.priceFormatter, placeholder: "$ 0.00", errorMessage: AttributedString(""), hintText: AttributedString(""), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit, isRequired: false, actionIcon: nil, action: nil)
39+
.id(self.priceId)
40+
41+
TextFieldFormView(title: "Number", text: self.$numeric, formatter: self.numberFormatter, placeholder: "1.234lbs", errorMessage: AttributedString(""), hintText: AttributedString(""), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit, isRequired: false, actionIcon: nil, action: nil)
42+
.id(self.numericId)
43+
} header: {
44+
Text("Custom Number Formatter - Text field form view")
45+
.font(.fiori(forTextStyle: .subheadline))
46+
.foregroundStyle(Color.preferredColor(.secondaryLabel))
47+
}
48+
Section {
49+
TextFieldFormView(title: "Date", text: self.$date, formatter: self.dateFormatter, placeholder: "AA 2025/01/01", errorMessage: AttributedString(""), maxTextLength: 13, hintText: AttributedString("AA YYYY/MM/DD"), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit, isRequired: false, actionIcon: nil, action: nil)
50+
.id(self.dateId)
51+
52+
TextFieldFormView(title: "Generic Text", text: self.$genericText, formatter: self.genericTextFormatter, placeholder: "+AA 123 456# a 2025/01/01 A*", errorMessage: AttributedString(""), maxTextLength: 28, hintText: AttributedString("+AA NNN NNNS X YYYY/MM/DD A*"), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit, isRequired: false, actionIcon: nil, action: nil)
53+
.id(self.genericTextId)
54+
55+
TextFieldFormView(title: "Generic Text2", text: self.$genericText2, formatter: self.genericText2Formatter, placeholder: "123+A* 456 789 A*", errorMessage: AttributedString(""), maxTextLength: 18, hintText: AttributedString("NNN+A* NNN NNN A*"), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit, isRequired: false, actionIcon: nil, action: nil)
56+
.id(self.genericText2Id)
57+
58+
} header: {
59+
Text("Generic Text Formatter - Text field form view")
60+
.font(.fiori(forTextStyle: .subheadline))
61+
.foregroundStyle(Color.preferredColor(.secondaryLabel))
62+
}
63+
Section {
64+
TitleFormView(text: self.$valueText, formatter: self.genericTextFormatter, placeholder: "+AA 123 456# a 2025/01/01 A*", hintText: AttributedString("+AA NNN NNNS X YYYY/MM/DD A*"), isCharCountEnabled: self.showsCharCount, allowsBeyondLimit: self.allowsBeyondLimit)
65+
.padding(.leading, -4)
66+
.padding(.trailing, -4)
67+
.id(self.valueTextId)
68+
} header: {
69+
Text("Generic Text Formatter - Title form view")
70+
.font(.fiori(forTextStyle: .subheadline))
71+
.foregroundStyle(Color.preferredColor(.secondaryLabel))
72+
}
73+
.listRowSeparator(.hidden, edges: .bottom)
74+
.environment(\.defaultMinListRowHeight, 0)
75+
.environment(\.defaultMinListHeaderHeight, 0)
76+
}
77+
}
78+
}
79+
80+
var phoneNumberFormatter: PhoneNumberFormatter {
81+
let formatter = PhoneNumberFormatter()
82+
return formatter
83+
}
84+
85+
var priceFormatter: CustomNumberFormatter {
86+
let formatter = CustomNumberFormatter()
87+
formatter.numberStyle = .currency
88+
return formatter
89+
}
90+
91+
var numberFormatter: CustomNumberFormatter {
92+
let formatter = CustomNumberFormatter()
93+
formatter.numberStyle = .decimal
94+
formatter.maximumFractionDigits = 3
95+
formatter.positiveSuffix = "lbs"
96+
return formatter
97+
}
98+
99+
var dateFormatter: GenericTextFormatter {
100+
let formatter = GenericTextFormatter()
101+
formatter.format = "AA YYYY/MM/DD"
102+
formatter.yearMinium = 1000
103+
formatter.yearMaximum = 3000
104+
return formatter
105+
}
106+
107+
var numericFormatter: GenericTextFormatter {
108+
let formatter = GenericTextFormatter()
109+
formatter.format = "+\\A\\* NNN NNN \\A\\*"
110+
return formatter
111+
}
112+
113+
var genericTextFormatter: GenericTextFormatter {
114+
let formatter = GenericTextFormatter()
115+
formatter.format = "+AA NNN NNNS X YYYY/MM/DD \\A\\*"
116+
return formatter
117+
}
118+
119+
var genericText2Formatter: GenericTextFormatter {
120+
let formatter = GenericTextFormatter()
121+
formatter.format = "NNN+\\A\\* NNN NNN \\A\\*"
122+
return formatter
123+
}
124+
}

0 commit comments

Comments
 (0)