diff --git a/Sources/TokamakCore/Views/Group.swift b/Sources/TokamakCore/Views/Group.swift new file mode 100644 index 000000000..89bbcd561 --- /dev/null +++ b/Sources/TokamakCore/Views/Group.swift @@ -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 { + 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 {} diff --git a/Sources/TokamakDOM/Views/Group.swift b/Sources/TokamakDOM/Views/Group.swift new file mode 100644 index 000000000..01cb28ec9 --- /dev/null +++ b/Sources/TokamakDOM/Views/Group.swift @@ -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 diff --git a/Sources/TokamakDemo/TokamakDemo.swift b/Sources/TokamakDemo/TokamakDemo.swift index 92fdc2528..ec7b02763 100644 --- a/Sources/TokamakDemo/TokamakDemo.swift +++ b/Sources/TokamakDemo/TokamakDemo.swift @@ -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) diff --git a/docs/progress.md b/docs/progress.md index f9f29177d..dbaa2bc81 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -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) | | @@ -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 @@ -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) | |