Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-gallagher committed Feb 26, 2024
0 parents commit 4e7ef43
Show file tree
Hide file tree
Showing 51 changed files with 9,030 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Build and test the DurationPicker package
name: CI

# Runs on pushes and pull requests targeting the default branch
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allow one concurrent deployment
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@v4
# For list of all Xcode and iOS versions, see https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
- name: Select Xcode 15.1
run: sudo xcode-select -s "/Applications/Xcode_15.1.app"
- name: List available iOS simulators
run: xcrun simctl list devices | grep -E "iPhone|iPad" | awk -F '[()]' '{print $1 ",", "iOS", $2}'
- name: Run tests
run: |
xcodebuild test \
-scheme DurationPicker \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15 Pro Max,OS=17.2' \
-configuration Debug \
|| exit 1; \
52 changes: 52 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Build and deploy DocC to GitHub pages. Based off of the following guide:
# https://maxxfrazer.medium.com/deploying-docc-with-github-actions-218c5ca6cad5
name: Documentation

# Runs on pushes targeting the default branch
on:
push:
branches:
- main

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
environment:
# Must be set to this for deploying to GitHub Pages
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: macos-13
steps:
- name: Checkout repository
uses: actions/checkout@v4
# For list of all Xcode and iOS versions, see https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
- name: Select Xcode
run: sudo xcode-select -s "/Applications/Xcode_15.0.1.app"
- name: Build DocC
run: |
xcodebuild docbuild -scheme DurationPicker \
-derivedDataPath /tmp/docbuild \
-destination 'generic/platform=iOS';
$(xcrun --find docc) process-archive \
transform-for-static-hosting /tmp/docbuild/Build/Products/Debug-iphoneos/DurationPicker.doccarchive \
--hosting-base-path DurationPicker \
--output-path docs;
echo "<script>window.location.href += \"/documentation/durationpicker\"</script>" > docs/index.html;
- name: Upload Artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload only docs directory from output above
path: 'docs'
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v3
id: deployment
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
/.build
xcuserdata
.swiftpm
.build
596 changes: 596 additions & 0 deletions Demo/DurationPickerDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD22D4682AC9E7A600442E8F"
BuildableName = "DurationPickerDemo.app"
BlueprintName = "DurationPickerDemo"
ReferencedContainer = "container:DurationPickerDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ADA18D8B2AC9ECDB00563833"
BuildableName = "DurationPickerDemoTests.xctest"
BlueprintName = "DurationPickerDemoTests"
ReferencedContainer = "container:DurationPickerDemo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD22D4682AC9E7A600442E8F"
BuildableName = "DurationPickerDemo.app"
BlueprintName = "DurationPickerDemo"
ReferencedContainer = "container:DurationPickerDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AD22D4682AC9E7A600442E8F"
BuildableName = "DurationPickerDemo.app"
BlueprintName = "DurationPickerDemo"
ReferencedContainer = "container:DurationPickerDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
35 changes: 35 additions & 0 deletions Demo/DurationPickerDemo/App/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/// MIT License
///
/// Copyright (c) 2023 Mac Gallagher
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all
/// copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
/// SOFTWARE.

import UIKit

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
UISceneConfiguration(
name: "Default Configuration",
sessionRole: connectingSceneSession.role)
}
}
41 changes: 41 additions & 0 deletions Demo/DurationPickerDemo/App/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/// MIT License
///
/// Copyright (c) 2023 Mac Gallagher
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all
/// copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
/// SOFTWARE.

import UIKit

final class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?

func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else {
return
}

window = UIWindow(windowScene: windowScene)
let navigationController = UINavigationController(rootViewController: DemoViewController())
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
}
}
85 changes: 85 additions & 0 deletions Demo/DurationPickerDemo/Demo/Adapter/DemoAdapter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/// MIT License
///
/// Copyright (c) 2023 Mac Gallagher
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in all
/// copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
/// SOFTWARE.

import DurationPicker
import UIKit

typealias DemoCellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, DemoDataSource.Item>

enum DemoAdapter {

static func makeCellProvider(viewModel: DemoViewModel,
delegate: DemoCellDelegate?) -> DemoDataSource.CellProvider {
let titleCellTransformer = DemoTitleCellTransformer.makeCellRegistration(viewModel: viewModel)

let datePickerCellRegistration = DemoDatePickerCellTransformer.makeCellRegistration(
viewModel: viewModel,
delegate: delegate)

let durationPickerCellRegistration = DemoDurationPickerCellTransformer.makeCellRegistration(
viewModel: viewModel,
delegate: delegate)

let menuButtonCellRegistration = DemoMenuButtonCellTransformer.makeCellRegistration(
viewModel: viewModel,
delegate: delegate)

let textFieldRegistration = DemoTextFieldCellTransformer.makeCellRegistration(
viewModel: viewModel,
delegate: delegate)

return { collectionView, indexPath, item in
switch item {
case .datePicker:
collectionView.dequeueConfiguredReusableCell(
using: datePickerCellRegistration,
for: indexPath,
item: item)
case .datePickerToggle:
collectionView.dequeueConfiguredReusableCell(
using: titleCellTransformer,
for: indexPath,
item: item)
case .durationPicker:
collectionView.dequeueConfiguredReusableCell(
using: durationPickerCellRegistration,
for: indexPath,
item: item)
case .durationPickerHourInterval,
.durationPickerMaximumDuration,
.durationPickerMinimumDuration,
.durationPickerMinuteInterval,
.durationPickerSecondInterval,
.durationPickerValue:
collectionView.dequeueConfiguredReusableCell(
using: textFieldRegistration,
for: indexPath,
item: item)
case .durationPickerPickerMode:
collectionView.dequeueConfiguredReusableCell(
using: menuButtonCellRegistration,
for: indexPath,
item: item)
}
}
}
}
Loading

0 comments on commit 4e7ef43

Please sign in to comment.