Skip to content

Commit 8754dc7

Browse files
Merge pull request #11 from SimformSolutionsPvtLtd/UNT-T20604-optimization
UNT-T20604-Optimization
2 parents d5a8fb0 + eca4e1b commit 8754dc7

32 files changed

Lines changed: 1419 additions & 474 deletions

Example/Example.xcodeproj/project.pbxproj

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88

99
/* Begin PBXBuildFile section */
1010
650720D32B194D2100AC1FB6 /* PickerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 650720D22B194D2100AC1FB6 /* PickerViewModel.swift */; };
11+
6520E7C42B2D9BDF008D7329 /* SSDateTimePicker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65AB6B7E2B289E49009EA7EC /* SSDateTimePicker.framework */; };
12+
6520E7C52B2D9BDF008D7329 /* SSDateTimePicker.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 65AB6B7E2B289E49009EA7EC /* SSDateTimePicker.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1113
6549D9AC2B2C4B4B0089EBB1 /* ThemeCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6549D9AB2B2C4B4B0089EBB1 /* ThemeCard.swift */; };
1214
6549D9B02B2C4DBA0089EBB1 /* View+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6549D9AF2B2C4DBA0089EBB1 /* View+Extension.swift */; };
1315
65AB6B0B2B283131009EA7EC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 65AB6B0D2B283131009EA7EC /* Localizable.strings */; };
14-
65AB6B102B2839F9009EA7EC /* ThemeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AB6B0F2B2839F9009EA7EC /* ThemeButton.swift */; };
16+
65AB6B102B2839F9009EA7EC /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AB6B0F2B2839F9009EA7EC /* Utils.swift */; };
1517
65AB6B122B283AED009EA7EC /* LocalizedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AB6B112B283AED009EA7EC /* LocalizedString.swift */; };
1618
65AB6B152B285309009EA7EC /* Color+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65AB6B142B285309009EA7EC /* Color+Extension.swift */; };
17-
65AB6B812B289EA8009EA7EC /* SSDateTimePicker.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65AB6B7E2B289E49009EA7EC /* SSDateTimePicker.framework */; settings = {ATTRIBUTES = (Required, ); }; };
1819
65E0584E2B0E3E850049A7BA /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E0584D2B0E3E850049A7BA /* ExampleApp.swift */; };
1920
65E058502B0E3E850049A7BA /* PickerExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E0584F2B0E3E850049A7BA /* PickerExampleView.swift */; };
2021
65E058522B0E3E860049A7BA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 65E058512B0E3E860049A7BA /* Assets.xcassets */; };
@@ -38,12 +39,26 @@
3839
};
3940
/* End PBXContainerItemProxy section */
4041

42+
/* Begin PBXCopyFilesBuildPhase section */
43+
6520E7C62B2D9BDF008D7329 /* Embed Frameworks */ = {
44+
isa = PBXCopyFilesBuildPhase;
45+
buildActionMask = 2147483647;
46+
dstPath = "";
47+
dstSubfolderSpec = 10;
48+
files = (
49+
6520E7C52B2D9BDF008D7329 /* SSDateTimePicker.framework in Embed Frameworks */,
50+
);
51+
name = "Embed Frameworks";
52+
runOnlyForDeploymentPostprocessing = 0;
53+
};
54+
/* End PBXCopyFilesBuildPhase section */
55+
4156
/* Begin PBXFileReference section */
4257
650720D22B194D2100AC1FB6 /* PickerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PickerViewModel.swift; sourceTree = "<group>"; };
4358
6549D9AB2B2C4B4B0089EBB1 /* ThemeCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeCard.swift; sourceTree = "<group>"; };
4459
6549D9AF2B2C4DBA0089EBB1 /* View+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Extension.swift"; sourceTree = "<group>"; };
4560
65AB6B0C2B283131009EA7EC /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
46-
65AB6B0F2B2839F9009EA7EC /* ThemeButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeButton.swift; sourceTree = "<group>"; };
61+
65AB6B0F2B2839F9009EA7EC /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = "<group>"; };
4762
65AB6B112B283AED009EA7EC /* LocalizedString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedString.swift; sourceTree = "<group>"; };
4863
65AB6B142B285309009EA7EC /* Color+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Extension.swift"; sourceTree = "<group>"; };
4964
65AB6B782B289E49009EA7EC /* SSDateTimePicker.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SSDateTimePicker.xcodeproj; path = ../SSDateTimePicker/SSDateTimePicker.xcodeproj; sourceTree = "<group>"; };
@@ -59,7 +74,7 @@
5974
isa = PBXFrameworksBuildPhase;
6075
buildActionMask = 2147483647;
6176
files = (
62-
65AB6B812B289EA8009EA7EC /* SSDateTimePicker.framework in Frameworks */,
77+
6520E7C42B2D9BDF008D7329 /* SSDateTimePicker.framework in Frameworks */,
6378
);
6479
runOnlyForDeploymentPostprocessing = 0;
6580
};
@@ -85,7 +100,7 @@
85100
65AB6B132B283AF2009EA7EC /* Common */ = {
86101
isa = PBXGroup;
87102
children = (
88-
65AB6B0F2B2839F9009EA7EC /* ThemeButton.swift */,
103+
65AB6B0F2B2839F9009EA7EC /* Utils.swift */,
89104
65AB6B112B283AED009EA7EC /* LocalizedString.swift */,
90105
6549D9AB2B2C4B4B0089EBB1 /* ThemeCard.swift */,
91106
);
@@ -168,6 +183,7 @@
168183
65E058462B0E3E850049A7BA /* Sources */,
169184
65E058472B0E3E850049A7BA /* Frameworks */,
170185
65E058482B0E3E850049A7BA /* Resources */,
186+
6520E7C62B2D9BDF008D7329 /* Embed Frameworks */,
171187
);
172188
buildRules = (
173189
);
@@ -260,7 +276,7 @@
260276
650720D32B194D2100AC1FB6 /* PickerViewModel.swift in Sources */,
261277
65E058502B0E3E850049A7BA /* PickerExampleView.swift in Sources */,
262278
65E0584E2B0E3E850049A7BA /* ExampleApp.swift in Sources */,
263-
65AB6B102B2839F9009EA7EC /* ThemeButton.swift in Sources */,
279+
65AB6B102B2839F9009EA7EC /* Utils.swift in Sources */,
264280
);
265281
runOnlyForDeploymentPostprocessing = 0;
266282
};
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1510"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "65E058492B0E3E850049A7BA"
18+
BuildableName = "Example.app"
19+
BlueprintName = "Example"
20+
ReferencedContainer = "container:Example.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
shouldAutocreateTestPlan = "YES">
31+
</TestAction>
32+
<LaunchAction
33+
buildConfiguration = "Debug"
34+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
35+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
36+
launchStyle = "0"
37+
useCustomWorkingDirectory = "NO"
38+
ignoresPersistentStateOnLaunch = "NO"
39+
debugDocumentVersioning = "YES"
40+
debugServiceExtension = "internal"
41+
allowLocationSimulation = "YES">
42+
<BuildableProductRunnable
43+
runnableDebuggingMode = "0">
44+
<BuildableReference
45+
BuildableIdentifier = "primary"
46+
BlueprintIdentifier = "65E058492B0E3E850049A7BA"
47+
BuildableName = "Example.app"
48+
BlueprintName = "Example"
49+
ReferencedContainer = "container:Example.xcodeproj">
50+
</BuildableReference>
51+
</BuildableProductRunnable>
52+
</LaunchAction>
53+
<ProfileAction
54+
buildConfiguration = "Release"
55+
shouldUseLaunchSchemeArgsEnv = "YES"
56+
savedToolIdentifier = ""
57+
useCustomWorkingDirectory = "NO"
58+
debugDocumentVersioning = "YES">
59+
<BuildableProductRunnable
60+
runnableDebuggingMode = "0">
61+
<BuildableReference
62+
BuildableIdentifier = "primary"
63+
BlueprintIdentifier = "65E058492B0E3E850049A7BA"
64+
BuildableName = "Example.app"
65+
BlueprintName = "Example"
66+
ReferencedContainer = "container:Example.xcodeproj">
67+
</BuildableReference>
68+
</BuildableProductRunnable>
69+
</ProfileAction>
70+
<AnalyzeAction
71+
buildConfiguration = "Debug">
72+
</AnalyzeAction>
73+
<ArchiveAction
74+
buildConfiguration = "Release"
75+
revealArchiveInOrganizer = "YES">
76+
</ArchiveAction>
77+
</Scheme>

Example/Example.xcodeproj/xcuserdata/rizwana.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,13 @@
1010
<integer>0</integer>
1111
</dict>
1212
</dict>
13+
<key>SuppressBuildableAutocreation</key>
14+
<dict>
15+
<key>65E058492B0E3E850049A7BA</key>
16+
<dict>
17+
<key>primary</key>
18+
<true/>
19+
</dict>
20+
</dict>
1321
</dict>
1422
</plist>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,21 @@ struct ThemeButton: ViewModifier {
2121
}
2222

2323
}
24+
25+
struct ClearBackgroundView: UIViewRepresentable {
26+
27+
func makeUIView(context: Context) -> UIView {
28+
return InnerView()
29+
}
30+
31+
func updateUIView(_ uiView: UIView, context: Context) {
32+
}
33+
34+
private class InnerView: UIView {
35+
override func didMoveToWindow() {
36+
super.didMoveToWindow()
37+
superview?.superview?.backgroundColor = .clear
38+
}
39+
}
40+
41+
}

Example/Example/View/PickerExampleView.swift

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
import SwiftUI
99
import SSDateTimePicker
10-
import Combine
1110

1211
struct PickerExampleView: View {
1312

14-
//MARK: - Property
15-
@State var showCalender: Bool = false
13+
//MARK: - Properties
14+
15+
@State var showDatePicker: Bool = false
16+
@State var showMultiDatePicker: Bool = false
17+
@State var showDateRangePicker: Bool = false
1618
@State var showTimePicker: Bool = false
1719
@State var displayCustomizedCalendar: Bool = false
1820
@State var selectedDate: Date = Date()
@@ -21,15 +23,21 @@ struct PickerExampleView: View {
2123

2224
//MARK: - Body
2325
var body: some View {
24-
ZStack {
25-
dateTimePickerExampleView
26-
27-
// Date Picker
28-
SSDatePicker(showCalender: $showCalender, calendarManager: ObservedObject(wrappedValue: pickerViewModel.datePickerManager))
29-
30-
// Time Picker
31-
SSTimePicker(showTimePicker: $showTimePicker, timePickerManager: pickerViewModel.timePickerManager)
32-
}
26+
dateTimePickerExampleView
27+
.fullScreenCover(isPresented: $showDatePicker) {
28+
datePicker
29+
}
30+
.fullScreenCover(isPresented: $showDateRangePicker, content: {
31+
dateRangePicker
32+
})
33+
.fullScreenCover(isPresented: $showMultiDatePicker, content: {
34+
multiDatePicker
35+
})
36+
.fullScreenCover(isPresented: $showTimePicker) {
37+
// Time Picker
38+
timePicker
39+
.background(ClearBackgroundView())
40+
}
3341

3442
}
3543

@@ -83,7 +91,7 @@ struct PickerExampleView: View {
8391
VStack(spacing: 10) {
8492
Text("\(LocalizedString.dateRangeSelectionExample)")
8593
.font(.callout)
86-
Text("\(LocalizedString.startDate) \(pickerViewModel.startDate?.monthDateYear ?? "-"), \(LocalizedString.endDate) \(pickerViewModel.endDate?.monthDateYear ?? "-")")
94+
Text("\(LocalizedString.startDate) \(pickerViewModel.selectedDateRange?.startDate.monthDateYear ?? "-"), \(LocalizedString.endDate) \(pickerViewModel.selectedDateRange?.endDate.monthDateYear ?? "-")")
8795
.font(.footnote)
8896
btnSelectDateRange
8997
}
@@ -92,8 +100,7 @@ struct PickerExampleView: View {
92100

93101
var btnSelectDateRange: some View {
94102
Button {
95-
pickerViewModel.configureForDateRangeSelection()
96-
showCalender.toggle()
103+
showDateRangePicker.toggle()
97104
} label: {
98105
Text(LocalizedString.selectDateRange)
99106
.themeButton()
@@ -118,40 +125,66 @@ struct PickerExampleView: View {
118125
Text(LocalizedString.selectTime)
119126
.themeButton()
120127
}
121-
122128
}
123129

124130
var btnSelectSingleDate: some View {
125131
Button {
126-
pickerViewModel.configureForSingleDateSelection()
127-
showCalender.toggle()
132+
showDatePicker.toggle()
128133
} label: {
129134
Text(LocalizedString.selectSingleDate)
130135
.themeButton()
131136
}
132137
}
133138

134-
var btnCustomizedPicker: some View {
135-
Button {
136-
pickerViewModel.customizedDatePicker()
137-
showCalender.toggle()
138-
} label: {
139-
Text(LocalizedString.customizedDatePicker)
140-
.themeButton()
141-
}
142-
}
143-
144139
var btnSelectMultipleDates: some View {
145140
Button {
146-
pickerViewModel.configureForMultipleDateSelection()
147-
showCalender.toggle()
141+
showMultiDatePicker.toggle()
148142
} label: {
149143
Text(LocalizedString.selectMultipleDate)
150144
.themeButton()
151-
152145
}
153146
}
154147

148+
var datePicker: some View {
149+
SSDatePicker(showDatePicker: $showDatePicker)
150+
.selectedDate(self.pickerViewModel.selectedDate)
151+
.onDateSelection({ date in
152+
self.pickerViewModel.selectedDate = date
153+
})
154+
.background(ClearBackgroundView())
155+
}
156+
157+
var dateRangePicker: some View {
158+
SSDatePicker(showDatePicker: $showDateRangePicker)
159+
.enableDateRangeSelection()
160+
.selectedDates(pickerViewModel.selectedDateRange)
161+
.onDateRangeSelection({ dateRange in
162+
pickerViewModel.selectedDateRange = dateRange
163+
})
164+
.background(ClearBackgroundView())
165+
}
166+
167+
var multiDatePicker: some View {
168+
SSDatePicker(showDatePicker: $showMultiDatePicker)
169+
.disableDates([Date()])
170+
.themeColor(pickerBackgroundColor: .lightGreen, primaryColor: .darkGreen)
171+
.enableMultipleDateSelection()
172+
.selectedDates(pickerViewModel.selectedDates)
173+
.onMultiDateSelection({ dates in
174+
pickerViewModel.selectedDates = dates
175+
})
176+
.background(ClearBackgroundView())
177+
}
178+
179+
var timePicker: some View {
180+
SSTimePicker(showTimePicker: $showTimePicker)
181+
.selectedTime(pickerViewModel.selectedTime)
182+
.buttonStyle(color: .darkGreen)
183+
.onTimeSelection { time in
184+
pickerViewModel.selectedTime = time
185+
}
186+
}
187+
155188
}
156189

157190
struct ContentView_Previews: PreviewProvider {

0 commit comments

Comments
 (0)