Commit Graph

157 Commits

Author SHA1 Message Date
Max Desiatov c5743c6437
Update .swiftformat and project formatting 2020-05-04 18:06:55 +01:00
Max Desiatov 8462bec94c
Remove unused .xcodeproj, update Runtime deps 2020-05-04 16:52:15 +01:00
Max Desiatov ca0c96fffb
Remove references to components and nodes 2020-04-11 23:31:05 +01:00
Max Desiatov 1378151316
Remove unused code, fix TupleView initializers 2020-04-11 22:15:25 +01:00
Max Desiatov e1fb4f7c32
Add TokamakDOM, ViewDeferredToRenderer protocol 2020-04-11 21:58:24 +01:00
Max Desiatov 76d9d62aef
Add HTML view with tag, attributes and content 2020-04-11 18:33:51 +01:00
Max Desiatov 9407dd0674
Migrate reconciler and TestRenderer to View API (#107)
* Migrate reconciler and AppKit renderer to View API

* Fix building tests, cleanup unused code

* Remove more unused code

* Remove TokamakAppKit, add ParentView/GroupView

* Remove unused code, make testMount pass

* Cleanup more unused code

* Add ValueStorage protocol

* Add getter/setter internal properties on State

* Fix more State test assertions

* Fix all the reconciler tests 🎉
2020-04-11 18:21:04 +01:00
Max Desiatov 62f43d30fb
Add Binding property wrapper, remove unused code (#106) 2020-04-07 15:26:42 +01:00
matvii d0016c3141
Add TokamakLogger (#104)
* Init TokamakLogger

* Add TokamakLogger

* Apply swiftformat

* Fix var name

* Add TokamakLogger to project

* Add TokamakLoggerTest

* Remove unused code form TokamakLogger

* Remove logLevel proxying

* Add TokamakLoggerTest

* Add TokamakLoggerTest

* Add TokamakLogger to TokamakCLI

* Remove logLevel assignment

* Add TokamakCLI options bloc to Linter.md

* Remove force unwrap

* Add Logger

* Refactor TokamakLogHandler

* Apply swift format

* Fix error names

* Make error enum public
2019-06-04 16:52:58 +03:00
Max Desiatov 8cdb19802c
Fix typos in comments 2019-05-31 09:57:32 +01:00
matvii 770e1c4b44
Lint components type (#102)
* Extend HooksRule on extension

* Add ComponentAsStructRule

* Fix typo

* Apply swiftformat

* Fix violation description

* Fix rule name
2019-05-30 17:41:03 +03:00
matvii 30a2b9dda3
Extend HooksRule on extension (#101)
* Extend HooksRule on extension

* Simplify HooksRule

* Remove return type

* Add FIXME

* Apply swiftformat
2019-05-30 16:34:54 +03:00
matvii 295315e7b0
Fix one render function rule (#100)
* Fix getComponents and OneRenderFunctionRule

* Fix RenderGetsHooksRule

* Refactor GetComponents

* Refactor Rules

* Fix RenderGetsHooksRule

* Extend Node children search

* Add tests to RenderGetsHooksRule

* Apply swiftformat

* Fix comments
2019-05-29 11:56:11 +03:00
matvii 69c563337e
Lint Rules of Hooks (#98)
* Make Node Equatable

* Extend Node methods

* Init HooksRule

* Update HooksRule tests

* Update Node compare function

* Add start position to Node in TokenVisitor.visitPre

* Update HooksRule test

* Refactor HooksRule

* Fix typo in comments

* Rename functions in the tests

* Fix typo in comment

* Move repeated code in function

* Move repeated code in function

* Remove repeated code

* Apply swiftformat

* Group repeated guards
2019-05-23 17:36:13 +03:00
matvii 7c500d6b25
Refactor OneRenderFunction rule (#97)
* Regenerate project

* Revert "Regenerate project"

This reverts commit 37e676bf0a.

* Rename getRender to getOneRender

* Add component type check to getOneRender

* Add negative lint test

* Add OneRenderFunction description

* Add negative tests to RuleOfHooks

* Add test file with two correct components

* Refactor OneRenderFunctionRule

* Apply swiftformat

* Remove return from catch

* Replace map with compactMap

* Refactor throw violations in OneRenderFunctionRule

* Fix var name typo
2019-05-20 18:45:02 +03:00
matvii 7d0b41ce4c
Move getRender to Node extension (#95)
* Make node final class

* Move getRender to Node extension

* Apply swiftformat

* Regenerate project
2019-05-18 16:12:54 +03:00
matvii 5c65df1375
Add xcodebuild exit status to travis (#93)
* Add exit status

* Fix Color

* Update travis.yml script

* Remove unused extension

* Add condition for safe

* Add Color tests

* Add codecov.yml
2019-05-14 15:00:26 +03:00
matvii 4f02218fdb
Lint rules of hooks (#92)
* Remove broken test

* Add OneRenderFunctionRule

* Init RenderCorespondToNonPureComponentProtocolRule

* Fix OneRenderFunctionRule

* Apply swiftformat

* Fix RenderCorespondToNonPureComponentProtocolRule

* Add render check to RenderCorespondToNonPureComponentProtocolRule

* Update TokenVisitor

* Update getNodes

* Add TokenLint helpers

Add GetRender, IsConformance, TokenTypes

* Remove RenderCorespondToNonPureComponentProtocolRule

* Format comments

* Fix GetRender

* Remove TokenTypes

* Replace strings with SyntaxKind rawValue

* Add function to walk in graph

* Add TokenVisitor init function

* Add GraphWalkers to project

* Update isConformance function

* Update OneRenderFunctionRule

* Update getFirstChildOf function

* Update GraphWalkers

* Add getRender function

* Add RenderGetsHooksRule

* Update RenderGetsHooksRule

* Update RenderGetsHooksRule

* Apply swiftformat

* Rename getNodes to children

* Remove render from GetRender

* Remove IsConformance

* Mode nodes helpers to `Node.swift`

* Add test to Node

* Fix Unused Optional Binding Violation

* Fix Leading Whitespace Violation

* Apply swiftformat

* Fix typos

* Fix typos

* Remove unused code

* Clean code

* Move isInherited to Node

* Refactor hasTokamakImport

* Refactor Node

* Add helpers to TokamakCLITests

* Refactor code

* Update TokamakCLI main

* Refactor GetRender

* Fix typo

* Refactor rules

* Refactor TokenVIsitor

* Add TokamakCLI to .travis.yml

* Move NodeStruct to ValidationTests

* Add TEST_PATH to TokamakCLI

* Refactor StyleViolation

* Refactor Rule

* Add SwiftCLI to Package

* Apply swiftformat

* Regenerate project

* Update project.pbxproj

* Remove package for swift-4.2
2019-05-14 10:12:47 +03:00
matvii ee1f2d93c8
Add SwiftCLI dependency to TokamakCLI (#89)
* Add public lintFile

* Add SwiftCLI package

* Add CLI to TokamakCLI

* Apply swiftformat

* Fix TokamakCLI version

* Fix typo

* Update TokamakCLI error catch

* Update TokamakCLI path

* Update Linter.md

* Remove SRCROOT

* Update Linter.md

* Update XcodeReporter

* Update project.pbxproj

* Remove commented print
2019-05-03 19:26:08 +03:00
matvii 4e2f4ab154
Make error output more readable (#87) 2019-05-02 14:00:15 +03:00
matvii 69afa7a917
Fix walkAndGrab (#86) 2019-05-02 12:37:18 +03:00
matvii 95239c7a20
Remove unused variables (#85) 2019-05-02 12:15:41 +03:00
matvii 1d1d159b55
Fix TokenVisitor handling of Range (#84)
* Fix TokenVisitor handling of Range

* Fix class name in TokamakLintTests

* Add testRange

* Fix algorithm to find the token range

* Add test to verify token range correctness

* Remove force unwrapping
2019-05-02 11:10:01 +03:00
matvii 3fa1253458
Fix TokamakLint types access scope (#83) 2019-05-01 14:28:36 +03:00
matvii cde8be4ab8
Add lintFolder function to TokamakCLI (#82)
* Add lintFolder

* Fix PropsIsEquatableRule
2019-04-29 16:21:20 +03:00
Max Desiatov 32c3739b90
Fix assert message in Components 2019-04-28 18:05:03 +01:00
matvii 6d0ac9b505
Refactor TokamakLint (#81)
* Add Protocols and Models to TokamakLint

* Refactor TokamakLint

* Fix PropsIsEquatable test

* Remove unready functional

* Update TokamakLint

* Remove  commented code

* Move unchanged method to protocol extension

* Remove internal

* Fix typo

* Remove unused property

* Format code

* Refactor PropsIsEquatableRule

* Remove lintFolder test from main.swift

* Remove unused variable

* Remove optional fields from Location

* Redactor RuleDescription and PropsIsEquatableRule

* Update Location.swift
2019-04-14 23:07:06 +03:00
matvii 472dca3d36
Add TokamakLint module (#79)
* Init TokamakLint

* Fix Package.swift

* Move TokamakLint to Source

* Add SwiftSyntax to TokamakLint dependencies

* Rename TokamakLint to TokamaCLI

* Rename Lint.swift to main.swift

* Update TokamakCLI

* Init Lint Test

* Gererate project

* Update package.swift

* Clean and build

* Add Lint module

* Init test for one file

* Init file to test props

* Add test to check Props is Equatable

* Add lint warning

* Add warning to Props is not conformance from Equatable

* Init Linter doc & clean files

* Clean up code

* Format code

* Fix TokamakCLITest

* Fix Lint functions

* Remove IOU from TokenVisitor with optional

* Remove Encodable conformance from Node

* Remove unused file

* Rename test file

* Add comment of usage to `TestPropsEquatable`

* Remove unwanted methods

* Add scheme variable to TokamakCLI

* Update Linter.md

* Update TokamakCLI scheme

* Update Tokamak project

* Refactor TokamaLint

* Fix typo

* Add negative test to TokamakCLI

* Change output error function

* Simplify TokamakLint

* Fix TokamakLintTests

* Add error print to TokamakCLI

* Add error print to TokamakCLI

* Remove escapeHtmlSpecialCharacters

* Add print error to TokamakLint

* Add LintError

* Remove unused LintError case

* Expand LintError message

* Format LintError

* Format LintError
2019-04-08 17:07:55 +03:00
matvii 822d527a75
Add TextView host component (#76)
* Add TextView host component

* Refactor TextViewExample

* Add TextViewDelegate to TextView

* Add applyScrollOptions to TextView

* Apply swiftformat
2019-03-29 11:25:38 +02:00
matvii b2cd397b28
Add applyScrollOptions to UIScrollView components (#75)
* Add applyScrollOptions to UIScrollView components

* Add ScrollOptions to CollectionView, ListView, ScrollView

* Rename scrollProps to scrollOptions

* Change ScrollOptions init in Example

* Refactor ScrollView

* Remove storage ScrollOptions in ScrollView
2019-03-27 18:50:13 +02:00
matvii 895e50b4b2
Move TabPresenter to Presenters folder (#74) 2019-03-25 20:11:51 +02:00
matvii d26a41de38
Add TabPresenter host component (#66)
* Init TabBar

* Update TabExample

* Add ref to TabBar

* Add TabBarControllerBox

* Remove Router.swift

* Merge master in tab-bar

* Add TabBarControllerDelegate subclass

* Add hook to TabBarDelegate

* Fix SwiftLint warnings

* Fix TabBarController

* Fix TabBarExample

* Comment out counter example

* Remove Roter Presenters

* Remove addChild from AppKit

* Rename TabController to TabPresenter

* Add function to delete tab in TabBarExample

* Add `parent` parameter to unmount

* Add ability to delete TabItem in TabBarExample

* Add badge, badgeColor, image, selectedImage to TabItem

* Fix unmount functions

* Remove force cast

* Comment out counter example

* Move repeated style to constant

* Rename TokamakTabPresenter to TokamakTabController

* Add TabContent component

* Fix MountedHostComponent mount

* Fix TabBarExample

* Fix TabBarExample

* Fix TabBarExample strings

* Fix TabBarExample

* Fix TabItem

* Fix TabBarExample variable name
2019-03-25 18:55:31 +02:00
Joannis Orlandos c8dd3088a9 Add colors decoded from a hexadecimal string (#70) 2019-03-21 06:37:53 +00:00
Max Desiatov 25fa624d7b
Add Throbber host component (#71)
This component is rendered to `UIActivityViewIndicator` in `TokamakUIKit`. This component would be a great helper for future examples that demonstrate asynchronous effects, e.g. networking.

* Add Throbber host component
* Make .gray Throbber variety the default
2019-03-20 13:01:41 +00:00
Max Desiatov 156b775c4e
Add hex init to Color, cleanup assertionFailure (#69)
* Add hex init to Color, cleanup assertionFailure
* Add doc comment
2019-03-19 12:40:03 +00:00
Max Desiatov ec695e36b5
Simplify CellProvider protocol (#65)
In most of the cases users wouldn't need to create cell providers with more than one identifier or more than one section. We would like the most common cases to be as easy to use as possible, this PR renames `SimpleCellProvider` to `CellProvider` and old `CellProvider` to `IdentifiedCellProvider`. Old `Model` associated type is now renamed to `Section` with a default array-based sections type, while the new `Model` associated type allows setting the element type directly. This helps users avoid thinking about nested arrays in the cases where multiple `ListView` sections are not needed.

* Simplify CellProvider protocol
* Fix AppKitRenderer compilation issue
* Fix formatting
2019-03-16 10:47:51 +00:00
Max Desiatov fe43b9b9b0
Add factory functions creating `SizeConstraint` (#67)
We had an existing `SizeConstraint` struct, which was correctly rendered to auto layout constraints, but there was no way for users to create `SizeConstraint` with the new auto layout syntax. This is fixed by adding extension functions on `Size` with the usual format. This now allows setting constraints for size with a constant value:

```swift
Size.equal(to: .init(width: 100, height: 200))
```

Or with a multiplier relative to other nodes:

```swift
Size.equal(to: .parent, multiplier: 0.5)
```

* Add factory functions creating `SizeConstraint`
* Apply fixes from new SwiftFormat
2019-03-15 18:30:19 +00:00
Max Desiatov 433cd9c1b6
Remove TabPresenter and AnyTabPresenter/Router (#64)
This cleans up unused component and redundant `Router` protocol as well us unused `AnyTabPresenter` protocol
2019-03-14 11:42:47 +00:00
Max Desiatov de0726914c
Add TokamakAppKit module (#60)
This also adds separate `TokamakDemo` module in the main project, which will host all examples that can be cross-platform. A few `Style` properties were removed, which were duplicated in UIKit and duplicated versions couldn't be cleanly mapped in AppKit. `contentMode` was moved from `Style` to `Image` as `NSView` doesn't have `contentMode` at all, and for UIKit the only use that I know of is related to `UIImage` anyway.

Resolves #1

* Mostly empty TokamakAppKit module, fix copyright text
* Add TokamakDemo module, working counter on macOS
* Fix layer props and accessibility for AppKit
* Fix linter issues, completely remove `center` prop
* Fix line length in NSViewComponent
* Remove unused and broken ScrollView for AppKit
* Add macOS column to StandardComponents.md
* Make contentMode on Image non-optional
* Fix missing initializer call in ImageView.swift
* Change the domain name for the docs dir
* Fix TokamakAppKit after text Children -> Props fix
2019-03-12 11:37:22 +00:00
Max Desiatov b195742f16
Enable `Children = [AnyNode]` for Button and Label components (#62)
When in the future we add more components that would be useful as children of `Button` and `Label`, for example components that render to `CAShapeLayer`, we won't be able to add them as children. The reason is that this node "slot" is taken by text of `String` type. I think it's better to make this API-breaking change before the initial release, even though we don't have a component for `CAShapeLayer` yet.

* Move `text` from Children to Props in Button/Label
* Fix unit-tests after text props change
2019-03-12 10:57:37 +00:00
matvii bb0b5854c1
Add CollectionView (#59)
* Init CollectionView

* Add Collection Example

* Add CollectionViewBox to project

* Format code

* Refactor Collection View

* Fix Collection View example style

* Add rule to hound.yml

* Format code

* Improve error message
2019-03-08 19:02:08 +02:00
matvii f7b5384c95
Add ScrollView (#58)
* Init ScrollView

* Add ScrollView component

* Update ScollView

* Update Scroll extension

* Fix Ref index

* Add scroll example with ref styling

* Init zoom

* Add contentInset, bounces, scrollsToTop to ScrollView

* Add alwaysBounceVertical to ScrollView

* Add alwaysBounceHorizontal, indicatorStyle to ScrollView

* Add scrollIndicatorInsets, showsHorizontalScrollIndicator, showsVerticalScrollIndicator to ScrollView

* Add isDirectionalLockEnabled, isPagingEnabled, isScrollEnabled to ScrollView

* Add maximumZoomScale, minimumZoomScale, zoomScale to ScrollView

* Add bouncesZoom to ScrollView

* Add extension to RefComponent

* Add zoom to Image example

* Add simple ScrollView example

* Format code
2019-03-06 14:04:22 +02:00
matvii a1b5d0388a
Update AnyNode initializater arguments order (#57)
* Update AnyNode initialization function arguments order

* Change node initialization function arguments order

* Fix arguments order
2019-03-04 14:59:05 +02:00
matvii 604a60d251
Add Snake Game to Example list (#56)
* Init snake game

* Replace [Any] state with [UnsafeMutableRawPointer]

* Broke ux

* Add Width init function

* Update Snake Game

* Remove ability to switch move direction to opposite

* Fix game board bound

* Add game over condition

* Add color to snake target

* Refactor code

* Add Gamepad to Snake Game

* Remove infinity loop

* Refactor code

* Refactor code

* Add Gameboard to Snake

* Reduce render function size

* Add Gamemenu

* Rename Gamemenu to GameMenu

* Format code

* Refactor code
2019-02-27 18:38:31 +02:00
Max Desiatov a570352abc
Rename Image to ImageView, add Image props (#55)
This allows adding props for components that accept images, for example `Switch` is now able to implement `onImage` and `offImage` props.

* Add separate (empty for now) Image prop
* Implement Image, add Switch {on,off}Image props
2019-02-27 08:54:49 +00:00
matvii 570c2677d6
Add TextField (#52)
* Add TextField

List of added props are: textColor, textAlignment, placeholder, clearsOnBeginEditing, clearButtonMode, autocapitalizationType, autocorrectionType, spellCheckingType.

* Add keyboardType to TextField

* Add keyboardAppearance to TextField

* Add returnKeyType to TextField

* Add borderStyle to TextField

* Update TextField target

* Add TextField example

* Fix TextFields position on example screen

* Fix placeholder typo

* Use implicit member expression

* Add isSecureTextEntry prop to TextField

* Fix TextField refs

* Add valueChangeEvent to UIControlComponent
2019-02-25 15:15:34 +02:00
Max Desiatov 923ffd02fd
Define and set RefTarget in TokamakUIKit (#54)
Also add `UIView.animate` animation effect to example code. Also removes redundant `Updatable` protocol.

Resolves #49 

* Define and set RefTarget in TokamakUIKit
* Add animation example
* Rename backgroundColor to currentColor
* Add comments to Animation example
2019-02-25 11:50:09 +00:00
Max Desiatov 5fabe139dd
Implement node ref updates in TestRenderer (#51)
This is a prerequisite for #49, the actual `UIKitRenderer` implementation will follow in a separate PR.
2019-02-23 11:30:48 +00:00
matvii a7ce2fab11
Expose accessibility configuration on view props (#50)
* Rename StyleProps to ViewProps

* Init new argument order

* Init accessibility

* Add Accessibility.swift to project

* Sort Style init arguments

* Reorder arguments in Example

* Add Props init to StackView

* Fix arguments order in test

* Expose accessibility configuration on view props

* Rename ViewProps to StyleProps
2019-02-22 13:41:44 +02:00
Max Desiatov f894a4d78e
Fix Swift 5 compatibility, refine Timer demo (#48) 2019-02-22 08:46:39 +00:00