Skip to content

Commit 4e7ef43

Browse files
committed
Initial commit
0 parents  commit 4e7ef43

File tree

51 files changed

+9030
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+9030
-0
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Build and test the DurationPicker package
2+
name: CI
3+
4+
# Runs on pushes and pull requests targeting the default branch
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
# Allow one concurrent deployment
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
runs-on: macos-13
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
# For list of all Xcode and iOS versions, see https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
23+
- name: Select Xcode 15.1
24+
run: sudo xcode-select -s "/Applications/Xcode_15.1.app"
25+
- name: List available iOS simulators
26+
run: xcrun simctl list devices | grep -E "iPhone|iPad" | awk -F '[()]' '{print $1 ",", "iOS", $2}'
27+
- name: Run tests
28+
run: |
29+
xcodebuild test \
30+
-scheme DurationPicker \
31+
-sdk iphonesimulator \
32+
-destination 'platform=iOS Simulator,name=iPhone 15 Pro Max,OS=17.2' \
33+
-configuration Debug \
34+
|| exit 1; \
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Build and deploy DocC to GitHub pages. Based off of the following guide:
2+
# https://maxxfrazer.medium.com/deploying-docc-with-github-actions-218c5ca6cad5
3+
name: Documentation
4+
5+
# Runs on pushes targeting the default branch
6+
on:
7+
push:
8+
branches:
9+
- main
10+
11+
# Allow one concurrent deployment
12+
concurrency:
13+
group: "pages"
14+
cancel-in-progress: true
15+
16+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
17+
permissions:
18+
contents: read
19+
pages: write
20+
id-token: write
21+
22+
jobs:
23+
build:
24+
environment:
25+
# Must be set to this for deploying to GitHub Pages
26+
name: github-pages
27+
url: ${{ steps.deployment.outputs.page_url }}
28+
runs-on: macos-13
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
# For list of all Xcode and iOS versions, see https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
33+
- name: Select Xcode
34+
run: sudo xcode-select -s "/Applications/Xcode_15.0.1.app"
35+
- name: Build DocC
36+
run: |
37+
xcodebuild docbuild -scheme DurationPicker \
38+
-derivedDataPath /tmp/docbuild \
39+
-destination 'generic/platform=iOS';
40+
$(xcrun --find docc) process-archive \
41+
transform-for-static-hosting /tmp/docbuild/Build/Products/Debug-iphoneos/DurationPicker.doccarchive \
42+
--hosting-base-path DurationPicker \
43+
--output-path docs;
44+
echo "<script>window.location.href += \"/documentation/durationpicker\"</script>" > docs/index.html;
45+
- name: Upload Artifact
46+
uses: actions/upload-pages-artifact@v2
47+
with:
48+
# Upload only docs directory from output above
49+
path: 'docs'
50+
- name: Deploy to GitHub Pages
51+
uses: actions/deploy-pages@v3
52+
id: deployment

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
/.build
3+
xcuserdata
4+
.swiftpm
5+
.build

Demo/DurationPickerDemo.xcodeproj/project.pbxproj

Lines changed: 596 additions & 0 deletions
Large diffs are not rendered by default.

Demo/DurationPickerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1500"
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 = "AD22D4682AC9E7A600442E8F"
18+
BuildableName = "DurationPickerDemo.app"
19+
BlueprintName = "DurationPickerDemo"
20+
ReferencedContainer = "container:DurationPickerDemo.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+
<Testables>
32+
<TestableReference
33+
skipped = "NO"
34+
parallelizable = "YES">
35+
<BuildableReference
36+
BuildableIdentifier = "primary"
37+
BlueprintIdentifier = "ADA18D8B2AC9ECDB00563833"
38+
BuildableName = "DurationPickerDemoTests.xctest"
39+
BlueprintName = "DurationPickerDemoTests"
40+
ReferencedContainer = "container:DurationPickerDemo.xcodeproj">
41+
</BuildableReference>
42+
</TestableReference>
43+
</Testables>
44+
</TestAction>
45+
<LaunchAction
46+
buildConfiguration = "Debug"
47+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
48+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49+
launchStyle = "0"
50+
useCustomWorkingDirectory = "NO"
51+
ignoresPersistentStateOnLaunch = "NO"
52+
debugDocumentVersioning = "YES"
53+
debugServiceExtension = "internal"
54+
allowLocationSimulation = "YES">
55+
<BuildableProductRunnable
56+
runnableDebuggingMode = "0">
57+
<BuildableReference
58+
BuildableIdentifier = "primary"
59+
BlueprintIdentifier = "AD22D4682AC9E7A600442E8F"
60+
BuildableName = "DurationPickerDemo.app"
61+
BlueprintName = "DurationPickerDemo"
62+
ReferencedContainer = "container:DurationPickerDemo.xcodeproj">
63+
</BuildableReference>
64+
</BuildableProductRunnable>
65+
</LaunchAction>
66+
<ProfileAction
67+
buildConfiguration = "Release"
68+
shouldUseLaunchSchemeArgsEnv = "YES"
69+
savedToolIdentifier = ""
70+
useCustomWorkingDirectory = "NO"
71+
debugDocumentVersioning = "YES">
72+
<BuildableProductRunnable
73+
runnableDebuggingMode = "0">
74+
<BuildableReference
75+
BuildableIdentifier = "primary"
76+
BlueprintIdentifier = "AD22D4682AC9E7A600442E8F"
77+
BuildableName = "DurationPickerDemo.app"
78+
BlueprintName = "DurationPickerDemo"
79+
ReferencedContainer = "container:DurationPickerDemo.xcodeproj">
80+
</BuildableReference>
81+
</BuildableProductRunnable>
82+
</ProfileAction>
83+
<AnalyzeAction
84+
buildConfiguration = "Debug">
85+
</AnalyzeAction>
86+
<ArchiveAction
87+
buildConfiguration = "Release"
88+
revealArchiveInOrganizer = "YES">
89+
</ArchiveAction>
90+
</Scheme>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// MIT License
2+
///
3+
/// Copyright (c) 2023 Mac Gallagher
4+
///
5+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
/// of this software and associated documentation files (the "Software"), to deal
7+
/// in the Software without restriction, including without limitation the rights
8+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
/// copies of the Software, and to permit persons to whom the Software is
10+
/// furnished to do so, subject to the following conditions:
11+
///
12+
/// The above copyright notice and this permission notice shall be included in all
13+
/// copies or substantial portions of the Software.
14+
///
15+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
/// SOFTWARE.
22+
23+
import UIKit
24+
25+
@main
26+
final class AppDelegate: UIResponder, UIApplicationDelegate {
27+
28+
func application(_ application: UIApplication,
29+
configurationForConnecting connectingSceneSession: UISceneSession,
30+
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
31+
UISceneConfiguration(
32+
name: "Default Configuration",
33+
sessionRole: connectingSceneSession.role)
34+
}
35+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/// MIT License
2+
///
3+
/// Copyright (c) 2023 Mac Gallagher
4+
///
5+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
/// of this software and associated documentation files (the "Software"), to deal
7+
/// in the Software without restriction, including without limitation the rights
8+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
/// copies of the Software, and to permit persons to whom the Software is
10+
/// furnished to do so, subject to the following conditions:
11+
///
12+
/// The above copyright notice and this permission notice shall be included in all
13+
/// copies or substantial portions of the Software.
14+
///
15+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
/// SOFTWARE.
22+
23+
import UIKit
24+
25+
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
26+
27+
var window: UIWindow?
28+
29+
func scene(_ scene: UIScene,
30+
willConnectTo session: UISceneSession,
31+
options connectionOptions: UIScene.ConnectionOptions) {
32+
guard let windowScene = scene as? UIWindowScene else {
33+
return
34+
}
35+
36+
window = UIWindow(windowScene: windowScene)
37+
let navigationController = UINavigationController(rootViewController: DemoViewController())
38+
window?.rootViewController = navigationController
39+
window?.makeKeyAndVisible()
40+
}
41+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/// MIT License
2+
///
3+
/// Copyright (c) 2023 Mac Gallagher
4+
///
5+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
/// of this software and associated documentation files (the "Software"), to deal
7+
/// in the Software without restriction, including without limitation the rights
8+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
/// copies of the Software, and to permit persons to whom the Software is
10+
/// furnished to do so, subject to the following conditions:
11+
///
12+
/// The above copyright notice and this permission notice shall be included in all
13+
/// copies or substantial portions of the Software.
14+
///
15+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
/// SOFTWARE.
22+
23+
import DurationPicker
24+
import UIKit
25+
26+
typealias DemoCellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, DemoDataSource.Item>
27+
28+
enum DemoAdapter {
29+
30+
static func makeCellProvider(viewModel: DemoViewModel,
31+
delegate: DemoCellDelegate?) -> DemoDataSource.CellProvider {
32+
let titleCellTransformer = DemoTitleCellTransformer.makeCellRegistration(viewModel: viewModel)
33+
34+
let datePickerCellRegistration = DemoDatePickerCellTransformer.makeCellRegistration(
35+
viewModel: viewModel,
36+
delegate: delegate)
37+
38+
let durationPickerCellRegistration = DemoDurationPickerCellTransformer.makeCellRegistration(
39+
viewModel: viewModel,
40+
delegate: delegate)
41+
42+
let menuButtonCellRegistration = DemoMenuButtonCellTransformer.makeCellRegistration(
43+
viewModel: viewModel,
44+
delegate: delegate)
45+
46+
let textFieldRegistration = DemoTextFieldCellTransformer.makeCellRegistration(
47+
viewModel: viewModel,
48+
delegate: delegate)
49+
50+
return { collectionView, indexPath, item in
51+
switch item {
52+
case .datePicker:
53+
collectionView.dequeueConfiguredReusableCell(
54+
using: datePickerCellRegistration,
55+
for: indexPath,
56+
item: item)
57+
case .datePickerToggle:
58+
collectionView.dequeueConfiguredReusableCell(
59+
using: titleCellTransformer,
60+
for: indexPath,
61+
item: item)
62+
case .durationPicker:
63+
collectionView.dequeueConfiguredReusableCell(
64+
using: durationPickerCellRegistration,
65+
for: indexPath,
66+
item: item)
67+
case .durationPickerHourInterval,
68+
.durationPickerMaximumDuration,
69+
.durationPickerMinimumDuration,
70+
.durationPickerMinuteInterval,
71+
.durationPickerSecondInterval,
72+
.durationPickerValue:
73+
collectionView.dequeueConfiguredReusableCell(
74+
using: textFieldRegistration,
75+
for: indexPath,
76+
item: item)
77+
case .durationPickerPickerMode:
78+
collectionView.dequeueConfiguredReusableCell(
79+
using: menuButtonCellRegistration,
80+
for: indexPath,
81+
item: item)
82+
}
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)