{"id":13777827,"url":"https://github.com/renaudjenny/SwiftClockUI","last_synced_at":"2025-05-11T11:34:15.264Z","repository":{"id":43080792,"uuid":"242364798","full_name":"renaudjenny/SwiftClockUI","owner":"renaudjenny","description":"SwiftUI library to display a clock. You can move the arms to change the time, change the style of the clock and customise some configurations.","archived":false,"fork":false,"pushed_at":"2023-03-05T10:09:20.000Z","size":9150,"stargazers_count":304,"open_issues_count":2,"forks_count":21,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-10T01:19:54.391Z","etag":null,"topics":["clock","ios","macos","swift","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/renaudjenny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-02-22T15:30:21.000Z","updated_at":"2025-05-09T06:29:24.000Z","dependencies_parsed_at":"2024-01-16T14:14:28.324Z","dependency_job_id":null,"html_url":"https://github.com/renaudjenny/SwiftClockUI","commit_stats":{"total_commits":316,"total_committers":1,"mean_commits":316.0,"dds":0.0,"last_synced_commit":"e2012408d166ebafa0f0c0cdf568c984e77c3ded"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renaudjenny%2FSwiftClockUI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renaudjenny%2FSwiftClockUI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renaudjenny%2FSwiftClockUI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renaudjenny%2FSwiftClockUI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renaudjenny","download_url":"https://codeload.github.com/renaudjenny/SwiftClockUI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253559404,"owners_count":21927577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clock","ios","macos","swift","swiftui"],"created_at":"2024-08-03T18:00:49.119Z","updated_at":"2025-05-11T11:34:14.862Z","avatar_url":"https://github.com/renaudjenny.png","language":"Swift","funding_links":[],"categories":["Swift","Clock","UI"],"sub_categories":["Content","Clock"],"readme":"# SwiftClockUI\n\n![Xcode Unit Test](https://github.com/renaudjenny/SwiftClockUI/workflows/Xcode%20Unit%20Test/badge.svg)\n\nClock UI for SwiftUI\n\nThis library has been tested\n* ✅💻 macOS Catalina 10.15.3\n* ✅💻 macOS Big Sur 11.6\n* ✅📱 iOS 13\n* ✅📱 iOS 14\n* ✅📱 iOS 15\n\n*For compatibility with Xcode version older than 13.3, I would recommend to checkout the 1.4.x tag, it should compile with Xcode 11 and greater*\n\n## Bind a date\n\n```swift\nstruct ContentView: View {\n    @State private var date = Date()\n\n    var body: some View {\n        ClockView().environment(\\.clockDate, $date)\n    }\n}\n```\n\nSimply set `.environment(\\.clockDate, $date)` `$date` has to be a binding.\nIf you want something constant (just for showing the time), you could pass `.constant(yourDate)`\n\n* Arms move when date are set (take hour and minute in account)\n* Move the Arms change the date (hour and minute depending on which arm you've moved)\n\n## Change Clock style\n\nThere is 4 different clock style:\n\nStyle | Picture\n------------ | -------------\nClassic | ![Clock View with Classic style](docs/assets/ClockViewClassic.png)\nArt Nouveau | ![Clock View with Art Nouveau style](docs/assets/ClockViewArtNouveau.png)\nDrawing | ![Clock View with Drawing style](docs/assets/ClockViewDrawing.png)\nSteampunk | ![Clock View with Steampunk style](docs/assets/ClockViewSteampunk.png)\n\nTo set the style: `.environment(\\.clockStyle, .steampunk)` for Steampunk style for instance.\n\n```swift\nstruct ContentView: View {\n    @State private var clockStyle: ClockStyle = .classic\n\n    var body: some View {\n        ClockView().environment(\\.clockStyle, clockStyle)\n    }\n}\n```\n\n`\\.clockStyle` is typed as `enum ClockStyle`  which is `Identifiable`, `CaseIterable`, and has a convenient method to get the description (in English): `public var description: String`\n\nIt's very useful when you want to iterate over this `enum` to let the user choose the clock style, for instance you can easily do something like this:\n\n```swift\nstruct StylePicker: View {\n    @Binding var clockStyle: ClockStyle\n\n    var body: some View {\n        Picker(\"Style\", selection: clockStyle) {\n            ForEach(ClockStyle.allCases) { style in\n                Text(style.description).tag(style)\n            }\n        }\n        .pickerStyle(SegmentedPickerStyle())\n    }\n}\n```\n\n## Change elements color\n\nYou can also change the color of Clock elements. Again with changing some `.environment` keys.\n\n```swift\nClockView()\n    .environment(\\.clockArmColors, ClockArmColors(\n        minute: .red,\n        hour: .blue\n    ))\n    .environment(\\.clockBorderColor, .orange)\n    .environment(\\.clockIndicatorsColor, .green)\n```\n\nIn light mode, you could expect a result like this:\n\n![Clock View with Classic style and some colors changed](docs/assets/ClockViewClassicAndColors.png)\n\n## Installation\n\n### Xcode\n\nYou can add SwiftToTen to an Xcode project by adding it as a package dependency.\n\n1. From the **File** menu, select **Swift Packages › Add Package Dependency...**\n2. Enter \"https://github.com/renaudjenny/SwiftClockUI\" into the package repository URL test field\n\n### As package dependency\n\nEdit your `Package.swift` to add this library.\n\n```swift\nlet package = Package(\n    ...\n    dependencies: [\n        .package(url: \"https://github.com/renaudjenny/SwiftClockUI\", from: \"2.0.0\"),\n        ...\n    ],\n    targets: [\n        .target(\n            name: \"\u003cYour project name\u003e\",\n            dependencies: [\"SwiftClockUI\"]),\n        ...\n    ]\n)\n```\n\n## App using this library\n\n* [📲 Tell Time UK](https://apps.apple.com/gb/app/tell-time-uk/id1496541173): https://github.com/renaudjenny/telltime\n\n## For maintainers\n\nIf you want to help maintaining this library, I would suggest to add this **git hooks** on `pre-commit`\n\nIn a terminal opened in the repo folder, executes these commands\n\n```bash\necho '#!/bin/sh' \u003e .git/hooks/pre-commit\necho '' \u003e\u003e .git/hooks/pre-commit\necho 'swiftlint' \u003e\u003e .git/hooks/pre-commit\nchmod +x .git/hooks/pre-commit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenaudjenny%2FSwiftClockUI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenaudjenny%2FSwiftClockUI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenaudjenny%2FSwiftClockUI/lists"}