Skip to content

Commit 788a7d7

Browse files
committed
Cleanup.
1 parent 3b7cb2d commit 788a7d7

File tree

26 files changed

+222
-315
lines changed

26 files changed

+222
-315
lines changed

Examples/DiffableTextAppXUIKit/App/Screens.Number/NumberScreen.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ struct NumberScreen: View {
3535

3636
NumberScreenOptionsWheel(context)
3737

38-
NumberScreenIntegerInterval("Bounds (9s)",
39-
interval: context.bounds.interval, in: context.boundsLimits)
38+
VStack(spacing: 16) {
39+
NumberScreenIntegerInterval("Bounds (9s)",
40+
interval: context.bounds.interval, in: context.boundsLimits)
4041

41-
NumberScreenIntegerInterval("Integer digits",
42-
interval: context.integer, in: context.integerLimits)
42+
NumberScreenIntegerInterval("Integer digits",
43+
interval: context.integer, in: context.integerLimits)
4344

44-
NumberScreenIntegerInterval("Fraction digits",
45-
interval: context.fraction, in: context.fractionLimits)
45+
NumberScreenIntegerInterval("Fraction digits",
46+
interval: context.fraction, in: context.fractionLimits)
47+
}
4648

4749
Spacer()
4850
}

Examples/DiffableTextAppXUIKit/App/Screens.Number/NumberScreenIntegerInterval.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//=----------------------------------------------------------------------------=
99

1010
import SwiftUI
11-
import Sliders
11+
import IntervalSliders
1212

1313
//*============================================================================*
1414
// MARK: Declaration
@@ -50,7 +50,7 @@ struct NumberScreenIntegerInterval: View {
5050
var body: some View {
5151
VStack(alignment: .leading) {
5252
Text(description).font(.subheadline.weight(.light))
53-
Sliders($interval.wrapped.values, in: limits)
53+
IntervalSlider($interval.wrapped.values, in: limits)
5454
}
5555
}
5656
}

Examples/DiffableTextAppXUIKit/DiffableTextAppXUIKit.xcodeproj/project.pbxproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
5507BD1427AD620900F5292D /* Segments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5507BD1327AD620900F5292D /* Segments.swift */; };
1111
5507BD1627AD66A800F5292D /* Wheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5507BD1527AD66A800F5292D /* Wheel.swift */; };
1212
5527C21327AA6C6A0098546E /* Interval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5527C21227AA6C6A0098546E /* Interval.swift */; };
13+
555E9DE02828DF5500613FD3 /* IntervalSliders in Frameworks */ = {isa = PBXBuildFile; productRef = 555E9DDF2828DF5500613FD3 /* IntervalSliders */; };
1314
55781F2D27AD39B0003D4252 /* Scroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55781F2C27AD39B0003D4252 /* Scroller.swift */; };
1415
55781F3127AD4500003D4252 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55781F3027AD4500003D4252 /* Constants.swift */; };
1516
557DAF2127BA493200D9F0E5 /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = 557DAF2027BA493200D9F0E5 /* Action.swift */; };
@@ -29,7 +30,6 @@
2930
55B38EF52827FAE6005159F4 /* NumberScreenIntegerInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B38EF42827FAE6005159F4 /* NumberScreenIntegerInterval.swift */; };
3031
55B38EF72827FBB9005159F4 /* NumberScreenOptionsWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B38EF62827FBB9005159F4 /* NumberScreenOptionsWheel.swift */; };
3132
55B38EFB28280F0F005159F4 /* Toggler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55B38EFA28280F0F005159F4 /* Toggler.swift */; };
32-
55C9EC4D27F9996A00DA6CEB /* Sliders in Frameworks */ = {isa = PBXBuildFile; productRef = 55C9EC4C27F9996A00DA6CEB /* Sliders */; };
3333
55DDC62C27A8D81D00B2AB4A /* Example.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DDC62B27A8D81D00B2AB4A /* Example.swift */; };
3434
55F2783927AD7C1C001400D7 /* PatternScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55F2783627AD7C1C001400D7 /* PatternScreen.swift */; };
3535
55FD23C727BA0335008F65E1 /* PatternScreenContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55FD23C627BA0335008F65E1 /* PatternScreenContext.swift */; };
@@ -40,7 +40,7 @@
4040
5507BD1327AD620900F5292D /* Segments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Segments.swift; sourceTree = "<group>"; };
4141
5507BD1527AD66A800F5292D /* Wheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wheel.swift; sourceTree = "<group>"; };
4242
5527C21227AA6C6A0098546E /* Interval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interval.swift; sourceTree = "<group>"; };
43-
555DCDC227F9993C00490B50 /* Sliders */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Sliders; path = Modules/Sliders; sourceTree = "<group>"; };
43+
555E9DDE2828DF4900613FD3 /* IntervalSliders */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = IntervalSliders; path = Modules/IntervalSliders; sourceTree = "<group>"; };
4444
55781F2C27AD39B0003D4252 /* Scroller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scroller.swift; sourceTree = "<group>"; };
4545
55781F3027AD4500003D4252 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
4646
557D9AB427F98C14008C317B /* Entitlements.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Entitlements.entitlements; sourceTree = "<group>"; };
@@ -73,8 +73,8 @@
7373
isa = PBXFrameworksBuildPhase;
7474
buildActionMask = 2147483647;
7575
files = (
76+
555E9DE02828DF5500613FD3 /* IntervalSliders in Frameworks */,
7677
557F7FBB27A81171001908D6 /* DiffableTextViews in Frameworks */,
77-
55C9EC4D27F9996A00DA6CEB /* Sliders in Frameworks */,
7878
);
7979
runOnlyForDeploymentPostprocessing = 0;
8080
};
@@ -85,7 +85,7 @@
8585
isa = PBXGroup;
8686
children = (
8787
557F7FB927A81116001908D6 /* DiffableTextViews */,
88-
555DCDC227F9993C00490B50 /* Sliders */,
88+
555E9DDE2828DF4900613FD3 /* IntervalSliders */,
8989
);
9090
name = Packages;
9191
sourceTree = "<group>";
@@ -112,7 +112,6 @@
112112
5589A1A227A7E3E30000F04A /* App */ = {
113113
isa = PBXGroup;
114114
children = (
115-
5589A1A327A7E3E30000F04A /* App.swift */,
116115
55F6F58627A7E53300BA26AB /* Assets */,
117116
55B38EE42827C90D005159F4 /* Screens.Number */,
118117
55A85FFC27A7E87C006CCCB7 /* Screens.Pattern */,
@@ -121,6 +120,7 @@
121120
55AA28D127A802AF003778FE /* Views.Routers */,
122121
55B8ABAB27AAAB9E00980626 /* Models */,
123122
559CA92B2828683800E6F369 /* Models.Observables */,
123+
5589A1A327A7E3E30000F04A /* App.swift */,
124124
);
125125
path = App;
126126
sourceTree = "<group>";
@@ -238,7 +238,7 @@
238238
name = DiffableTextAppXUIKit;
239239
packageProductDependencies = (
240240
557F7FBA27A81171001908D6 /* DiffableTextViews */,
241-
55C9EC4C27F9996A00DA6CEB /* Sliders */,
241+
555E9DDF2828DF5500613FD3 /* IntervalSliders */,
242242
);
243243
productName = iOS;
244244
productReference = 5589A1A027A7E3E30000F04A /* DiffableTextAppXUIKit.app */;
@@ -529,13 +529,13 @@
529529
/* End XCConfigurationList section */
530530

531531
/* Begin XCSwiftPackageProductDependency section */
532-
557F7FBA27A81171001908D6 /* DiffableTextViews */ = {
532+
555E9DDF2828DF5500613FD3 /* IntervalSliders */ = {
533533
isa = XCSwiftPackageProductDependency;
534-
productName = DiffableTextViews;
534+
productName = IntervalSliders;
535535
};
536-
55C9EC4C27F9996A00DA6CEB /* Sliders */ = {
536+
557F7FBA27A81171001908D6 /* DiffableTextViews */ = {
537537
isa = XCSwiftPackageProductDependency;
538-
productName = Sliders;
538+
productName = DiffableTextViews;
539539
};
540540
/* End XCSwiftPackageProductDependency section */
541541
};

Examples/DiffableTextAppXUIKit/DiffableTextAppXUIKit.xcodeproj/xcshareddata/xcschemes/DiffableTextAppXUIKit.xcscheme

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@
3434
ReferencedContainer = "container:../..">
3535
</BuildableReference>
3636
</BuildActionEntry>
37+
<BuildActionEntry
38+
buildForTesting = "YES"
39+
buildForRunning = "YES"
40+
buildForProfiling = "YES"
41+
buildForArchiving = "YES"
42+
buildForAnalyzing = "YES">
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "IntervalSliders"
46+
BuildableName = "IntervalSliders"
47+
BlueprintName = "IntervalSliders"
48+
ReferencedContainer = "container:Modules/IntervalSliders">
49+
</BuildableReference>
50+
</BuildActionEntry>
3751
</BuildActionEntries>
3852
</BuildAction>
3953
<TestAction

Examples/DiffableTextAppXUIKit/Modules/Sliders/.gitignore renamed to Examples/DiffableTextAppXUIKit/Modules/IntervalSliders/.gitignore

File renamed without changes.

Examples/DiffableTextAppXUIKit/Modules/Sliders/Package.swift renamed to Examples/DiffableTextAppXUIKit/Modules/IntervalSliders/Package.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,24 @@
1111
import PackageDescription
1212

1313
//*============================================================================*
14-
// MARK: Sliders
14+
// MARK: IntervalSliders
1515
//*============================================================================*
1616

1717
let package = Package(
18-
name: "Sliders",
18+
name: "IntervalSliders",
1919
platforms: [
2020
.iOS(.v15),
2121
],
2222
products: [
2323
//=--------------------------------------=
24-
// Sliders
24+
// IntervalSliders
2525
//=--------------------------------------=
26-
.library(
27-
name: "Sliders",
28-
targets: ["Sliders"])
26+
.library(name: "IntervalSliders", targets: ["IntervalSliders"])
2927
],
3028
targets: [
3129
//=--------------------------------------=
32-
// Sliders
30+
// IntervalSliders
3331
//=--------------------------------------=
34-
.target(name: "Sliders"),
32+
.target(name: "IntervalSliders"),
3533
]
3634
)

Examples/DiffableTextAppXUIKit/Modules/Sliders/Sources/Sliders/Sliders.swift renamed to Examples/DiffableTextAppXUIKit/Modules/IntervalSliders/Sources/IntervalSliders/IntervalSlider.swift

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import SwiftUI
1313
// MARK: Declaration
1414
//*============================================================================*
1515

16-
public struct Sliders: View, HasInterval {
16+
public struct IntervalSlider: View {
1717

1818
//=------------------------------------------------------------------------=
1919
// MARK: State
@@ -25,60 +25,61 @@ public struct Sliders: View, HasInterval {
2525
// MARK: Initializers
2626
//=------------------------------------------------------------------------=
2727

28-
@inlinable public init(_ values: Binding<(CGFloat, CGFloat)>, in limits: ClosedRange<CGFloat>) {
28+
@inlinable public init(_ values: Binding<(CGFloat, CGFloat)>,
29+
in limits: ClosedRange<CGFloat>) {
2930
self.interval = Interval(values, in: limits)
3031
}
3132

3233
//=------------------------------------------------------------------------=
3334
// MARK: Body
3435
//=------------------------------------------------------------------------=
35-
36+
3637
@inlinable public var body: some View {
37-
foundation.overlay(controls)
38-
}
39-
40-
//=------------------------------------------------------------------------=
41-
// MARK: Components
42-
//=------------------------------------------------------------------------=
43-
44-
@inlinable var foundation: some View {
45-
Track().frame(maxWidth: .infinity, minHeight: radius, maxHeight: radius)
46-
}
47-
48-
@inlinable var controls: some View {
49-
GeometryReader {
50-
Controls(interval, in: $0)
38+
ZStack {
39+
//=----------------------------------=
40+
// Track
41+
//=----------------------------------=
42+
Track()
43+
//=----------------------------------=
44+
// Controls
45+
//=----------------------------------=
46+
GeometryReader { geometry in
47+
Controls(interval, in: geometry)
48+
}
49+
.padding(.horizontal, 0.5 * Constants.radius)
5150
}
52-
.padding(.horizontal, 0.5 * radius)
51+
.frame(maxWidth: .infinity)
52+
.frame(height: Constants.radius)
5353
}
5454
}
5555

5656
//=----------------------------------------------------------------------------=
5757
// MARK: Initializers
5858
//=----------------------------------------------------------------------------=
5959

60-
extension Sliders {
60+
extension IntervalSlider {
6161

6262
//=------------------------------------------------------------------------=
6363
// MARK: Integer
6464
//=------------------------------------------------------------------------=
6565

66-
@inlinable public init<Value>(_ values: Binding<(Value, Value)>,
67-
in limits: ClosedRange<Value>) where Value: BinaryInteger {
66+
@inlinable public init<T>(_ values: Binding<(T, T)>,
67+
in limits: ClosedRange<T>) where T: BinaryInteger {
6868
//=--------------------------------------=
69-
// MARK: Get
69+
// Get
7070
//=--------------------------------------=
7171
self.init(Binding {(
7272
CGFloat(values.wrappedValue.0),
7373
CGFloat(values.wrappedValue.1))
7474
//=--------------------------------------=
75-
// MARK: Set
75+
// Set
7676
//=--------------------------------------=
77-
} set: { xxxxxxxxxxx in let newValue = (
78-
Value(xxxxxxxxxxx.0.rounded()),
79-
Value(xxxxxxxxxxx.1.rounded()))
77+
} set: {
78+
let newValue = (
79+
T($0.0.rounded()),
80+
T($0.1.rounded()))
8081
//=----------------------------------=
81-
// MARK: Set Nonduplicate Values
82+
// Must Be Unique
8283
//=----------------------------------=
8384
if values.wrappedValue != newValue {
8485
values.wrappedValue = newValue
@@ -107,7 +108,7 @@ struct Sliders_Previews: View, PreviewProvider {
107108
//=------------------------------------------------------------------------=
108109

109110
var body: some View {
110-
Sliders($interval, in: 0...6)
111+
IntervalSlider($interval, in: 0...6)
111112
}
112113

113114
//=------------------------------------------------------------------------=

Sources/DiffableTextViewsXUIKit/Helpers/UIView.swift renamed to Examples/DiffableTextAppXUIKit/Modules/IntervalSliders/Sources/IntervalSliders/Models/Constants.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,20 @@
77
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
88
//=----------------------------------------------------------------------------=
99

10-
#if canImport(UIKit)
11-
12-
import UIKit
10+
import SwiftUI
1311

1412
//*============================================================================*
15-
// MARK: Extension
13+
// MARK: Declaration
1614
//*============================================================================*
1715

18-
extension UIView {
16+
@usableFromInline enum Constants {
1917

2018
//=------------------------------------------------------------------------=
21-
// MARK: Accessors
19+
// MARK: State
2220
//=------------------------------------------------------------------------=
2321

24-
@inlinable var userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection {
25-
UIView.userInterfaceLayoutDirection(for: semanticContentAttribute)
26-
}
22+
@usableFromInline static let coordinates: UInt8 = 33
23+
@usableFromInline static let radius: CGFloat = 27
24+
@usableFromInline static let thickness: CGFloat = 04
25+
@usableFromInline static let dragging: Animation = .linear(duration: 0.125)
2726
}
28-
29-
#endif

Examples/DiffableTextAppXUIKit/Modules/Sliders/Sources/Sliders/Models/Context.swift renamed to Examples/DiffableTextAppXUIKit/Modules/IntervalSliders/Sources/IntervalSliders/Models/Context.swift

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import SwiftUI
1313
// MARK: Declaration
1414
//*============================================================================*
1515

16-
@usableFromInline final class Context {
16+
@dynamicMemberLookup @usableFromInline final class Context {
1717

1818
//=------------------------------------------------------------------------=
1919
// MARK: State
@@ -29,36 +29,16 @@ import SwiftUI
2929
@inlinable init(_ interval: Interval, proxy: GeometryProxy) {
3030
self.interval = interval; self.layout = Layout(interval, in: proxy)
3131
}
32-
}
33-
34-
//*============================================================================*
35-
// MARK: Declaration
36-
//*============================================================================*
37-
38-
@usableFromInline protocol HasContext: HasInterval, HasLayout {
39-
40-
//=------------------------------------------------------------------------=
41-
// MARK: Context
42-
//=------------------------------------------------------------------------=
43-
44-
@inlinable var context: Context { get }
45-
}
46-
47-
//=----------------------------------------------------------------------------=
48-
// MARK: Details
49-
//=----------------------------------------------------------------------------=
50-
51-
extension HasContext {
5232

5333
//=------------------------------------------------------------------------=
5434
// MARK: Accessors
5535
//=------------------------------------------------------------------------=
5636

57-
@inlinable var interval: Interval {
58-
context.interval
37+
@inlinable subscript<T>(dynamicMember keyPath: KeyPath<Layout, T>) -> T {
38+
layout[keyPath: keyPath]
5939
}
6040

61-
@inlinable var layout: Layout {
62-
context.layout
41+
@inlinable subscript<T>(dynamicMember keyPath: KeyPath<Interval, T>) -> T {
42+
interval[keyPath: keyPath]
6343
}
6444
}

0 commit comments

Comments
 (0)