Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Group implementation #150

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Sources/TokamakCore/Views/Group.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

public struct Group<Content> {
let content: Content
}

extension Group: View where Content: View {
public init(@ViewBuilder content: () -> Content) {
self.content = content()
}

public var body: Never {
neverBody("Group")
}
}

extension Group: ParentView where Content: View {
public var children: [AnyView] { (content as? ParentView)?.children ?? [AnyView(content)] }
}

extension Group: GroupView where Content: View {}
17 changes: 17 additions & 0 deletions Sources/TokamakDOM/Views/Group.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2020 Tokamak contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import TokamakCore

public typealias Group = TokamakCore.Group
22 changes: 12 additions & 10 deletions Sources/TokamakDemo/TokamakDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ struct TokamakDemoView: View {
Spacer()
}
VStack {
Counter(count: 5, limit: 15)
.padding()
.background(Color(red: 0.9, green: 0.9, blue: 0.9, opacity: 1.0))
.border(Color.red, width: 3)
ZStack {
Text("I'm on bottom")
Text("I'm forced to the top")
.zIndex(1)
Text("I'm on top")
Group {
Counter(count: 5, limit: 15)
.padding()
.background(Color(red: 0.9, green: 0.9, blue: 0.9, opacity: 1.0))
.border(Color.red, width: 3)
ZStack {
Text("I'm on bottom")
Text("I'm forced to the top")
.zIndex(1)
Text("I'm on top")
}
.padding(20)
}
.padding(20)
ForEachDemo()
TextDemo()
#if canImport(TokamakDOM)
Expand Down
30 changes: 15 additions & 15 deletions docs/progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Table columns:
| | | |
| --- | ---------------------------------------------------------------------- | :-: |
| | [Form](https://developer.apple.com/documentation/swiftui/form) | |
| | [Group](https://developer.apple.com/documentation/swiftui/group) | |
| | [Group](https://developer.apple.com/documentation/swiftui/group) | |
| | [GroupBox](https://developer.apple.com/documentation/swiftui/groupbox) | |
| | [Section](https://developer.apple.com/documentation/swiftui/section) | |

Expand All @@ -110,7 +110,7 @@ Table columns:

| | | |
| --- | -------------------------------------------------------------------- | :-: |
| ✅ | [Spacer](https://developer.apple.com/documentation/swiftui/spacer) | |
| ✅ | [Spacer](https://developer.apple.com/documentation/swiftui/spacer) | |
| | [Divider](https://developer.apple.com/documentation/swiftui/divider) | |

### Architectural Views
Expand Down Expand Up @@ -140,22 +140,22 @@ Table columns:

### Shapes

| | | |
| --- | ------------------------------------------------------------------------------------------ | :-: |
| 🚧 | [Rectangle](https://developer.apple.com/documentation/swiftui/rectangle) | |
| 🚧 | [RoundedRectangle](https://developer.apple.com/documentation/swiftui/roundedrectangle) | |
| 🚧 | [Ellipse](https://developer.apple.com/documentation/swiftui/ellipse) | |
| 🚧 | [Circle](https://developer.apple.com/documentation/swiftui/circle) | |
| 🚧 | [Capsule](https://developer.apple.com/documentation/swiftui/capsule) | |
| | | |
| --- | -------------------------------------------------------------------------------------- | :-: |
| 🚧 | [Rectangle](https://developer.apple.com/documentation/swiftui/rectangle) | |
| 🚧 | [RoundedRectangle](https://developer.apple.com/documentation/swiftui/roundedrectangle) | |
| 🚧 | [Ellipse](https://developer.apple.com/documentation/swiftui/ellipse) | |
| 🚧 | [Circle](https://developer.apple.com/documentation/swiftui/circle) | |
| 🚧 | [Capsule](https://developer.apple.com/documentation/swiftui/capsule) | |

### Paths

| | | |
| --- | ------------------------------------------------------------------------------------------ | :-: |
| 🚧 | [Path](https://developer.apple.com/documentation/swiftui/path) | |
| | | |
| --- | -------------------------------------------------------------- | :-: |
| 🚧 | [Path](https://developer.apple.com/documentation/swiftui/path) | |

### Styles

| | | |
| --- | ------------------------------------------------------------------------------------------ | :-: |
| 🚧 | [Color](https://developer.apple.com/documentation/swiftui/color) | |
| | | |
| --- | ---------------------------------------------------------------- | :-: |
| 🚧 | [Color](https://developer.apple.com/documentation/swiftui/color) | |