* Add Image view
* Add image to demo
* Update progress.md
* Alt text
* Use Bundle type to load images, remove systemName
* Add `logo-header.png` resource to `TokamakDemo`
* Reduce image size in the demo
* Allow bundles passed to `Image` to be optional
* Pass `nil` as a default `bundle` to `Image`
Co-authored-by: Max Desiatov <max@desiatov.com>
Resolve#287.
The `checked` attribute is a peculiar one, as any value on it keeps the checkbox checked. Attribute updates in `DOMRenderer` don't handle removals of attributes, but this seems to be the only case where this is relevant. I've added special handling for this attribute and checkbox inputs, and also had to declare `HTMLAttribute.checked` to set `isUpdatedAsProperty: true` on it for it to fully work.
Resolves, but adds no tests cases to the test suite for #294. See the issue for the detailed description of the problem.
I will add end-to-end tests for this in future PRs.
I've tested these cases manually so far:
```swift
struct Choice: View {
@State private var choice = false
var body: some View {
HStack {
Button("Trigger") {
choice.toggle()
}
if choice {
Group {
Text("true")
Text("true")
}
} else {
VStack {
Text("false")
}
}
Text("end")
}
}
}
```
Note the `Group` view with multiple children in this one, it uncovered required checks for `GroupView` conformance.
Also tested these more simple cases:
```swift
struct Choice: View {
@State private var choice = false
var body: some View {
HStack {
Button("Trigger") {
choice.toggle()
}
if choice {
Group {
// single child
Text("true")
}
} else {
VStack {
Text("false")
}
}
Text("end")
}
}
}
```
and
```swift
struct Choice: View {
@State private var choice = false
var body: some View {
HStack {
Button("Trigger") {
choice.toggle()
}
if choice {
// single child, no nesting
Text("true")
} else {
VStack {
Text("false")
}
}
Text("end")
}
}
}
```
* Ignore xcodeproj generated by SwiftPM
* Update to use official OpenCombine to avoid Xcode build error
* Use forked version with ObservableObject implementation
* Fix ambigious error
* Ignore SwiftPM edit mode package
* Update toolchain version
Requires #276 to be merged, as earlier versions of JavaScriptKit can't be depended on in macOS builds due to unsafe flags.
* Add Link View
* Add Publish support
* Remove #if checks
* Upgrade swift snapshot
* Try swiftwasm-action@main
* Remove Publish support from this repo
* Remove TokamakPublish target
* Allow tests to be run on macOS
* Update `ci.yml` to build and run the test product
* Trigger CI on all PRs without branch restrictions
* Rename linux_build to swiftwasm_build in ci.yml
Co-authored-by: Carson Katri <carson.katri@gmail.com>
* Add Link View
* Add Publish support
* Remove #if checks
* Upgrade swift snapshot
* Try swiftwasm-action@main
* Remove Publish support from this repo
* Remove TokamakPublish target
Looks like the Danger action duplicates warning comments. The new SwiftLint action does not, although warnings only show up in the diff view, which I think is an acceptable trade-off.
This PR requires `carton` 0.6.0 that you can install from Homebrew as usual.
To cleanly manage scheduler closures, new `JSScheduler` class is introduced that conforms to OpenCombine's `Scheduler` protocol. I think it will be moved to OpenCombineJS in the future.
* Fix compatibility with JavaScriptKit 0.7
* Formatting update
* Specify `carton` 0.6.0 as a requirement
* Optimize immediate schedule function
* Update formatting
Property assignment does not update SVG elements. We may want to use properties instead of `setAttribute` in the future for optimizations. For now I think that `setAttribute` works in all cases, including SVG, and seems safer to me.
Resolves#278.
* Use setAttribute, not properties to fix SVG update
* Add HTMLAttribute to cleanly apply DOM updates
* Add doc comment to HTMLAttribute
* Update Sources/TokamakStaticHTML/Views/HTML.swift
Co-authored-by: Jed Fox <git@jedfox.com>
* Use static func property in TokamakDOM/TextField.swift
* Make `static func property` public
* Declare `static let value` on `HTMLAttribute`
Co-authored-by: Jed Fox <git@jedfox.com>
* Slider MVP
* Update progress.md
* Update Slider.swift
* Update SliderDemo.swift
* Allow any BinaryFloatingPoint
* Add Mac Catalyst Tokamak demo
* Add basic onEditingChanged support
This likely has bugs if you touch down multiple fingers on the slider then lift one finger.
* Demo improvements
* Update ScrollView to match SwiftUI
This isn’t documented but it visually appears to wrap the content in a VStack
* Restyle the sliders
* Update Slider.swift
* Make convert functions private
* Fix line length
* Update progress.md and FIXMEs
* Wrap comments
This allows specifying 0.3 (to be released after this PR is merged) dependency on Tokamak in `carton` templates, otherwise branch/commit dependencies in our `Package.swift` can't be correctly resolved.
`swift test` is temporarily disabled on macOS as the upstream Swift toolchain doesn't support unsafe flags in the JavaScriptKit dependency together with a `from` constraint. We could run it on Linux, but my OpenCombine fork doesn't support Linux builds yet (logged as #263).
Resolves#158.
Fixes a bug where `NavigationView` destination was reset after scene phase changes (or any re-renders caused by environment changes for that matter).
This was caused by `@ObservedObject` destination being recreated, now `@StateObject` persists it across re-renders.
The `setter` property of the `ValueStorage` protocol is now moved to a separate `WritableValueStorage` protocol. The reasoning is that `StateObject` doesn't need its wrapped value to be set directly as it operates on it by reference, not by value, thus `StateObject` doesn't need any wrapped value setters.
This is just an empty API at the moment. I hope it can be implemented purely in the `deferredBody` of `GeometryReader` with [the ResizeObserver API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) without requiring any tweaks in the `Renderer` protocol or the reconciler.
Seems like I need the `domRef` modifier that writes `JSObjectRef` to a given binding working first, as discussed in #231.
* Use the latest 5.3 snapshot in `.swift-version`
These SwiftWasm snapshots should be more stable in general and also have a workaround for https://github.com/swiftwasm/JavaScriptKit/issues/6 included. They still use the old metadata layout, so Runtime and OpenCombine dependencies had to be updated in `Package.swift` for `@ObservableObject` to work with these snapshots.
* Fix linter warning