Skip to content

Commit

Permalink
Merge pull request #44 from fummicc1/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
fummicc1 authored Feb 14, 2023
2 parents 4d1dba8 + b435752 commit 80a21a3
Show file tree
Hide file tree
Showing 3,223 changed files with 3,623 additions and 2,411 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"object": {
"pins": [
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "10bc670db657d11bdd561e07de30a9041311b2b1",
"version": "1.1.0"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/apple/swift-docc-symbolkit",
"state": {
"branch": null,
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34",
"version": "1.0.0"
}
}
]
},
"version": 1
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,4 @@
uuid = "B622ED48-586E-471B-B0F0-EF3D8D3A536B"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "59AF7BA7-41DA-4165-BF9D-1B199580FBAC"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../Sources/SimpleRoulette/Sources/Pie/RouletteView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "49"
endingLineNumber = "49"
landmarkName = "body"
landmarkType = "24">
<Locations>
<Location
uuid = "59AF7BA7-41DA-4165-BF9D-1B199580FBAC - 1a677cebfd2ba691"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #2 (SimpleRoulette.RouletteState) -&gt; () in closure #1 (SwiftUI.GeometryProxy) -&gt; &lt;&lt;opaque return type of SwiftUI.View.onReceive&lt;&#x3c4;_0_0 where &#x3c4;_1_0: Combine.Publisher, &#x3c4;_1_0.Failure == Swift.Never&gt;(_: &#x3c4;_1_0, perform: (&#x3c4;_1_0.Output) -&gt; ()) -&gt; some&gt;&gt;.0 in closure #1 () -&gt; SwiftUI.TupleView&lt;(SwiftUI.AnyView, &lt;&lt;opaque return type of SwiftUI.View.frame(width: Swift.Optional&lt;CoreGraphics.CGFloat&gt;, height: Swift.Optional&lt;CoreGraphics.CGFloat&gt;, alignment: SwiftUI.Alignment) -&gt; some&gt;&gt;.0)&gt; in SimpleRoulette.RouletteView.body.getter : some"
moduleName = "Demo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/fumiyatanaka/Work/SwiftDev/SimpleRoulette/Sources/SimpleRoulette/Sources/Pie/RouletteView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "45"
endingLineNumber = "45"
offsetFromSymbolStart = "428">
</Location>
<Location
uuid = "59AF7BA7-41DA-4165-BF9D-1B199580FBAC - 27f654bb7441e984"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 () -&gt; () in closure #2 (SimpleRoulette.RouletteState) -&gt; () in closure #1 (SwiftUI.GeometryProxy) -&gt; &lt;&lt;opaque return type of SwiftUI.View.onReceive&lt;&#x3c4;_0_0 where &#x3c4;_1_0: Combine.Publisher, &#x3c4;_1_0.Failure == Swift.Never&gt;(_: &#x3c4;_1_0, perform: (&#x3c4;_1_0.Output) -&gt; ()) -&gt; some&gt;&gt;.0 in closure #1 () -&gt; SwiftUI.TupleView&lt;(SwiftUI.AnyView, &lt;&lt;opaque return type of SwiftUI.View.frame(width: Swift.Optional&lt;CoreGraphics.CGFloat&gt;, height: Swift.Optional&lt;CoreGraphics.CGFloat&gt;, alignment: SwiftUI.Alignment) -&gt; some&gt;&gt;.0)&gt; in SimpleRoulette.RouletteView.body.getter : some"
moduleName = "Demo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/fumiyatanaka/Work/SwiftDev/SimpleRoulette/Sources/SimpleRoulette/Sources/Pie/RouletteView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "46"
endingLineNumber = "46"
offsetFromSymbolStart = "44">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
103 changes: 61 additions & 42 deletions Examples/Shared/DemoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,69 @@ import SimpleRoulette

@main
struct DemoApp: App {

@State private var title: String = "Demo"

var body: some Scene {
WindowGroup {
ContentView(
model: RouletteModel(
parts: [
PartData(
index: 0,
content: .label("Swift"),
area: .flex(3),
fillColor: Color.red
),
PartData(
index: 1,
content: .label("Kotlin"),
area: .flex(1),
fillColor: Color.purple
),
PartData(
index: 2,
content: .label("JavaScript"),
area: .flex(2),
fillColor: Color.yellow
),
PartData(
index: 3,
content: .label("Dart"),
area: .flex(1),
fillColor: Color.green
),
PartData(
index: 4,
content: .label("Python"),
area: .flex(2),
fillColor: Color.blue
),
PartData(
index: 5,
content: .label("C++"),
area: .degree(60),
fillColor: Color.orange
),
]
)
)
/// please change ``DemoApp/roulette`` and ``DemoApp/content``
roulette.navigationTitle(title)
// content
}
}

var roulette: some View {
RouletteView(
parts: partDatas
)
.startOnAppear(automaticallyStopAfter: 5) { part in
guard let text = part.content.text else {
return
}
title = text
}
}

var content: some View {
ContentView(
model: RouletteModel(
parts: partDatas
)
)
}

var partDatas: [PartData] {
[
PartData(
content: .label("Swift"),
area: .flex(3),
fillColor: Color.red
),
PartData(
content: .label("Kotlin"),
area: .flex(1),
fillColor: Color.purple
),
PartData(
content: .label("JavaScript"),
area: .flex(2),
fillColor: Color.yellow
),
PartData(
content: .label("Dart"),
area: .flex(1),
fillColor: Color.green
),
PartData(
content: .label("Python"),
area: .flex(2),
fillColor: Color.blue
),
PartData(
content: .label("C++"),
area: .degree(60),
fillColor: Color.orange
),
]
}
}
92 changes: 71 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Create `Package.swift` and add dependency like the following.

```swift
dependencies: [
.package(url: "https://github.com/fummicc1/SimpleRoulette.git", from: "1.2.0")
.package(url: "https://github.com/fummicc1/SimpleRoulette.git", from: "1.3.0")
// or
.package(url: "https://github.com/fummicc1/SimpleRoulette.git", branch: "main")
]
Expand All @@ -39,7 +39,7 @@ dependencies: [
Create `Podfile` and add dependency like the following.

```ruby
pod 'SimpleRoulette', '~> 1.2'
pod 'SimpleRoulette', '~> 1.3'
```

### Carthage
Expand All @@ -54,57 +54,115 @@ github "fummicc1/SimpleRoulette"

### RouletteView

All you need to know is just `RouletteView` and `PartData`.
`RouletteView` confirms to `View`, so you can use it like the follwing.

````swift
```swift
struct ContentView: View {

@ObservedObject var model: RouletteModel
var body: some View {
RouletteView(
parts: partDatas
)
.startOnAppear(automaticallyStopAfter: 5) { part in
guard let text = part.content.text else {
return
}
title = text
}
}

var partDatas: [PartData] {
[
PartData(
content: .label("Swift"),
area: .flex(3),
fillColor: Color.red
),
PartData(
content: .label("Kotlin"),
area: .flex(1),
fillColor: Color.purple
),
PartData(
content: .label("JavaScript"),
area: .flex(2),
fillColor: Color.yellow
),
PartData(
content: .label("Dart"),
area: .flex(1),
fillColor: Color.green
),
PartData(
content: .label("Python"),
area: .flex(2),
fillColor: Color.blue
),
PartData(
content: .label("C++"),
area: .degree(60),
fillColor: Color.orange
),
]
}
}
````

## RouletteModel

If you want to pause / restart roulette. Please use `RouletteModel` like the following.

```swift
struct ContentView: View {

@StateObject var model: RouletteModel

var body: some View {
VStack {
RouletteView(
model: model
)
}.onAppear { model.start(speed: .random()) }
RouletteView(model: model)
}.onAppear {
model.start()
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
model.pause() // you can pause
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
model.restart() // you can restart
}
}
}
}
}

// Call ContentView
ContentView(
model: RouletteModel(
PartData(
index: 0,
content: .label("Swift"),
area: .flex(3),
fillColor: Color.red
),
PartData(
index: 1,
content: .label("Kotlin"),
area: .flex(1),
fillColor: Color.purple
),
PartData(
index: 2,
content: .label("JavaScript"),
area: .flex(2),
fillColor: Color.yellow
),
PartData(
index: 3,
content: .label("Dart"),
area: .flex(1),
fillColor: Color.green
),
PartData(
index: 4,
content: .label("Python"),
area: .flex(2),
fillColor: Color.blue
),
PartData(
index: 5,
content: .label("C++"),
area: .degree(60),
fillColor: Color.orange
Expand All @@ -113,14 +171,6 @@ ContentView(
)
```

### RouletteModel

RouletteModel is `ObservableObject`. You can observe the event that roulette has been stopped and what is the stop via `onDecide` Publisher.

## Usage

`RouletteModel.start` function immediately start roulette. If you would stop roulette automatically, please specify the duration in seconds of rotation at `automaticallyStopAfter: Double?` parameter. Default value of `automaticallyStopAfter` is nil which means that roulette continues rotating unless you call `RouletteModel.stop` method.

## Documentation

- [Documentation](https://fummicc1.github.io/SimpleRoulette/documentation/simpleroulette)
Expand Down
6 changes: 3 additions & 3 deletions SimpleRoulette.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Pod::Spec.new do |spec|
#

spec.name = "SimpleRoulette"
spec.version = "1.2.0"
spec.summary = "Create Roulette with ease."
spec.version = "1.3.0"
spec.summary = "SwiftUI library to create Roulette with ease."

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
Expand Down Expand Up @@ -81,7 +81,7 @@ Pod::Spec.new do |spec|
# Supports git, hg, bzr, svn and HTTP.
#

spec.source = { :git => "https://github.com/fummicc1/SimpleRoulette.git", :tag => "1.2.0" }
spec.source = { :git => "https://github.com/fummicc1/SimpleRoulette.git", :tag => "1.3.0" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
Loading

0 comments on commit 80a21a3

Please sign in to comment.