Commit Graph

548 Commits

Author SHA1 Message Date
Max Desiatov 5f3822257d
Add `TokamakShim` module to simplify imports (#192)
Adding this module as a dependency, Tokamak users would only need to add a single import regardless of the platform they're targeting. Thus, instead of

```swift
#if canImport(SwiftUI)
import SwiftUI
#else
import TokamakDOM
#endif
```

a single `import TokamakShim` is enough. `TokamakShim` re-exports correct modules based on a target platform.

I've also renamed the `TokamakDemo Native` directory to `NativeDemo` for brevity.

`xcodebuild` output in the `macos_demo_build` job is now passed to `xcpretty` for more readable build logs.
2020-07-19 20:53:27 +01:00
Jed Fox 743d9a0de8
Organize all the re-exports into a single file (#193)
* Organize all the re-exports into a single file

Hypothetically, Core.swift could be copy-pasted unmodified into any renderer

* Update ZStack.swift
2020-07-19 10:46:19 -04:00
Max Desiatov b495a2447d
Add `Picker` and `PopUpButtonPickerStyle` as default (#149)
The rest of the styles will be implemented as separate PRs.

Additionally, `LazyHGrid` demo is wrapped in a horizontal `ScrollView` so that it can be viewed in portrait phone layout in the native demo.
2020-07-17 12:57:40 +01:00
Carson Katri 93927f41f5
Add @EnvironmentObject (#170) 2020-07-17 07:54:49 -04:00
Jed Fox 314a6f3a5a
Allow non-consecutive state variables (#191)
* Fix error when state variables are non-consecutive

* Update one of the demos to cause it to fail without the fix
2020-07-16 17:10:09 -04:00
Max Desiatov ffa686c7dc
Add @ObservedObject implementation (#171)
This pulls a fork of OpenCombine that can be compiled with the same SwiftWasm snapshot we use in `main`.

The only caveat is that this doesn't work for `ObservableObject`s that are subclasses of other classes with `@Published` properties. This issue needs to be fixed in [the Runtime library fork](https://github.com/MaxDesiatov/Runtime). Since this is a rare case, and fixing it wouldn't change this `@ObservedObject` implementation, I think it's ready for review as is.
2020-07-16 20:39:47 +01:00
Max Desiatov 8f23ac979f
Avoid AnyView in the Counter code (#168)
It's not needed there as `ViewBuilder` is smarter now.

The macOS SwiftUI SDK even with Xcode 12 still doesn't have the `@ViewBuilder` attribute on the `View` protocol, so we have to build for iOS on CI to make the native buld pass.

Resolves #167, which wasn't caused by protocol conformance problems, but by infinite recursion in the `_ConditionalContent` implementation of `body`.

Adds assorted formatting fixes, some are apparently caused by the newer `swiftformat` version.
2020-07-16 19:17:04 +01:00
Max Desiatov 31d90fd129
Fix wording in README.md 2020-07-15 21:43:29 +01:00
Max Desiatov d172e04f7c
Mention `#webassembly` SwiftPM Slack channel in README.md (#187)
Was asked about this a few times in the last few days, probably worth surfacing it in `README.md` 🙂
2020-07-15 12:17:02 +01:00
Carson Katri 11af0f8d98
Add LazyHGrid and LazyVGrid (#179)
* Add LazyHGrid and LazyVGrid

* iOS support & progress doc
2020-07-14 13:28:23 -04:00
Max Desiatov 9cf606ef0c
Implement `static func Binding<Value>.constant` (#178)
Unrelated formatting changes were added by the SwiftFormat pre-commit hook.
2020-07-13 16:36:27 +01:00
Carson Katri 2b3010a631
Match SwiftUI Color (#177) 2020-07-13 11:27:55 -04:00
Carson Katri 97406f1383
+ operator for Text (#174) 2020-07-12 09:00:26 -04:00
Carson Katri f891edd928
Extend Path to match SwiftUI (#172)
* Initial Path element and subpath support

* Fix ambiguous .init

* Add more path commands

* Fix line length

* Fix macOS build

* Add missing file to xcodeproj
2020-07-11 09:10:25 -04:00
Max Desiatov b9ade79df1
Clean up .github/workflows/label.yml 2020-07-07 22:26:31 +01:00
Carson Katri 1f2203d652
Allow modified views to fill their parent if a child requires it (#165)
* Allow modified views to fill their parent if a child requires it

* Rename orderDependent to isOrderDependent
2020-07-07 10:25:46 -04:00
Max Desiatov 444d7e371e
Update copyright years in the LICENSE file 2020-07-07 15:01:03 +01:00
Max Desiatov 7ffa9ed326
Build macOS demo on CI (#164)
This builds against SwiftUI, not Tokamak, but allows us to test compatibility in some sort of automated manner.
2020-07-06 21:03:17 +01:00
Carson Katri 50be7b16f7
Add List and related Views (#147)
* List and Divider

* Add DisclosureGroup and OutlineGroup

* Add aria attributes

* OutlineGroup List initializers

* Make only chevron clickable

* ListStyle

* Fix line lengths

* Fix demo

* Section

* Modify progressmd

* Remove useless comment

* Switch to hr element

* Disable Divider for last row

* Make list and outline style defaults constant

* Minor cleanup

* ListStyleDeferredToRenderer

* Fix demo
2020-07-06 15:46:59 -04:00
Carson Katri aedab8ca05
ViewBuilder buildIf fix (#162)
* ViewBuilder buildIf fix

* Add FIXME
2020-07-06 07:49:10 -04:00
Max Desiatov e2966fe700
Use `let` instead of `var` in `TextFieldStyleKey: EnvironmentKey` (#160) 2020-07-05 20:23:40 +01:00
Max Desiatov b0bb124f5c
Add large_tuple to disabled_rules in .swiftlint.yml 2020-07-05 16:42:00 +01:00
Max Desiatov dc64554427
Update Acknowledgments section in README.md (#157)
It now explicitly references React architecture and gives credit to SwiftUI API designers.
2020-07-03 23:08:45 +01:00
Max Desiatov ebcac6db70
Add Group implementation (#150) 2020-07-02 23:21:33 +01:00
Max Desiatov afba02d2cc
Update AnyView status in progress.md (#151)
IDK, is there something that SwiftUI `AnyView` can do that ours can't? ¯\_(ツ)_/¯
2020-07-02 23:21:14 +01:00
Max Desiatov fda1381001
Use a range instead of an array in ForEach (#153)
* Use a range instead of an array in ForEachDemo

This a very minor optimization, it won't need to allocate an array of integers anymore in addition to already holding the array of views in memory. Also tests that the range initializer of `ForEach` is working properly.

* Avoid creating a redundant array in ForEach.init
2020-07-02 23:20:33 +01:00
Carson Katri eec7562e08
Documentation comments (#143) 2020-07-02 13:44:49 -04:00
Jed Fox e65269189a
Add Xcode project and native targets (#142)
* Match the Color API to the native one

* Extract the demo view to its own file

* Add Xcode project and native targets

* Fix Color

* Delete UISceneDelegate.swift

* Fix line length

* Tokamak Native → TokamakDemo Native

* Add exports for styles, fix typo
2020-07-02 13:04:29 -04:00
Max Desiatov 38ca0093a7
Add AppearanceActionModifier, onAppear/onDisappear (#145)
This is required to unblock #136 as I think it would make sense for the `DOMEnvironment` view there to add/remove its color scheme listener in `onAppear`/`onDisappear` closures.

I've also restored full SwiftUI compatibility in the signature of `func modifier<Modifier>(_ modifier: Modifier)`. Consequently `ViewDeferredToRenderer` had to be implemented on `ModifiedContent` then instead of `_ViewModifier_Content` to make it work.
2020-07-02 16:12:08 +01:00
Max Desiatov 878c42335e
Add doc comment to the ViewDeferredToRenderer protocol (#144)
* Add doc comment to the ViewDeferredToRenderer protocol

* Fix formatting
2020-07-02 14:41:05 +01:00
Carson Katri 525cefe6bc
Allow @Environment on all MountedViews (#146) 2020-07-02 09:36:16 -04:00
Max Desiatov 1632db77b9
Rename MountedView to MountedViews for consistency 2020-07-01 23:22:06 +01:00
Max Desiatov b0947ce71c
Remove unused files from TokamakCore 2020-07-01 23:17:35 +01:00
Max Desiatov 04ee6d9e30
Rename MountedComponents directory to MountedView 2020-07-01 23:15:39 +01:00
Jed Fox 17463c43ed
Add TextFieldStyle (#125)
* Add TextFieldStyle

* oops

* Comment out the Semantic UI CSS

* Move the DOM-specific stuff to TokamakDOM

* SecureFIeld is implemented!

* Remove commented-out code

Co-authored-by: Max Desiatov <max@desiatov.com>

* Remove unncessary underscore and proxy method

* Enable building on Xcode for access to IDE tools

* Add an environment variable for TextField style

* Remove mandatory init()

* Update Sources/TokamakCore/CGStubs.swift

Co-authored-by: Max Desiatov <max@desiatov.com>

* Update Sources/TokamakCore/CGStubs.swift

Co-authored-by: Max Desiatov <max@desiatov.com>

* Remove the lock

* Move file to sources folder

Co-authored-by: Max Desiatov <max@desiatov.com>
2020-07-01 14:43:09 -04:00
Max Desiatov 8b62cc67a2
Credit SwiftWebUI in a special way in README.md (#140) 2020-07-01 19:36:02 +01:00
Max Desiatov f85e26a350
Add "Modular structure" section to `README.md` (#137)
* Add "Modular structure" section to `README.md`

This clarifies the general structure of the `Tokamak` package and lays out "the underscore rules" to indicate "package private" access for symbols that aren't intended for public use.

* Refine wording in the "Modular structure" section
2020-07-01 14:41:24 +01:00
Max Desiatov 5adc7b2cff
Conditionally import SwiftUI in README.md example (#138)
This demonstrates portability of Tokamak a bit more in my opinion. Also, we had a redundant closing brace in the example code 🤦‍♂️
2020-07-01 14:40:50 +01:00
Carson Katri 1d71fe0c7d
Implement Environment (#135)
* Environment impl

* Fix line lengths

* Danger and review fixes

* rename _modifyEnvironment to modifyEnvironment
2020-07-01 08:28:09 -04:00
Max Desiatov b1b5693b66
Add logo to README.md (#133)
* Add logo to README.md

* Fix header logo layout in README.md

* Increase header logo width to 640px

* Add Jed Fox as a maintainer to README.md

* Update README.md

Co-authored-by: Jed Fox <git@twopointzero.us>
2020-07-01 08:28:32 +01:00
Max Desiatov 5f47cb485d
Refine formatting 2020-06-30 23:39:30 +01:00
Max Desiatov 5439933c45
Use proxy types for package private properties (#127)
I think that while public functions giving access to private properties does the job, they pollute the global namespace of `TokamakCore`, while for every property you need to create a separate function. These functions read a bit weird at their place of use, so I'm wondering whether the Proxy pattern could work better here. While it's more verbose, I find it a bit more readable, while also adding some sort of structure here for grouping multiple properties if needed.
2020-06-30 20:09:47 +01:00
Carson Katri f9f11a0113
Shape, Path, and some related modifiers (#119)
* Initial Shape support

* Border modifier

* Better demo

* Make Path conform to Shape

* Implement clipShape

* Add shapes/path/shapestyles to progress.md
2020-06-30 15:00:16 -04:00
Max Desiatov bc8196e9ef
Add `todo` to `disabled_rules` in .swiftlint.yml 2020-06-30 17:30:44 +01:00
Carson Katri 98a107f7fe
Add ScrollView (#128)
* Add ScrollView
* Root styles for ScrollView and Stack
2020-06-30 12:29:06 -04:00
Max Desiatov 0e910756c0
Allow refactor PR labels in label.yml 2020-06-30 16:01:14 +01:00
Max Desiatov 36aaf24878
Avoid running Danger on PRs from forked repos 2020-06-30 15:09:30 +01:00
Carson Katri e40a701752
Add Spacer support (#122)
1. If a Stack has a Spacer as a child, we need to fill the width or height of the parent so the Spacer's flex-grow: 1; works.
2. If a Stack has a child Stack along the cross axis (HStack with a nested VStack and vice vera) we need to fill the cross axis
3. If a Stack has a child Stack along the same axis (HStack with a nested HStack) we need to fill the axis.
2020-06-30 09:31:25 -04:00
Max Desiatov 9f5877e8ab
Update EmptyView status in progress.md 2020-06-30 14:23:39 +01:00
Max Desiatov 18fc89c4a1
Re-enable linting with Danger (#124)
Probably the reason for Danger failures was the bot account not having access to the project.
2020-06-30 13:39:56 +01:00