Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnEstropia committed Dec 3, 2024
1 parent 1dcaad5 commit d6b53da
Show file tree
Hide file tree
Showing 9 changed files with 408 additions and 53 deletions.
71 changes: 71 additions & 0 deletions Development/Demo/MyBook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,77 @@ let myBook = Book.init(
}
)

#Preview("Simple Sample") {
Text("Yo there!")
.foregroundStyle(Color.green)
}

#Preview {
Text("NO TITLE!")
.foregroundStyle(Color.purple)
}

@available(iOS 17.0, *)
#Preview("States Sample") {
@Previewable @State var state: Int = 1

VStack {
Text("Aloha \(state)")
Button(
action: { state += 1 },
label: { Text("+") }
)
}
}

@available(iOS 17.0, *)
#Preview("UIView Sample") {
{
var state: Int = 1

let label = UILabel()
label.text = "Test \(state)"

let button = UIButton(
configuration: .bordered(),
primaryAction: .init { _ in
state += 1
label.text = "Test \(state)"
}
)
button.setTitle("+", for: .normal)
let stack = UIStackView(arrangedSubviews: [label, button])
stack.spacing = 8
return stack
}()
}

@available(iOS 17.0, *)
#Preview("UIViewController Sample") {
{
let controller = UIViewController()
controller.view.backgroundColor = .systemMint
var state: Int = 1

let label = UILabel()
label.text = "Test \(state)"

let button = UIButton(
configuration: .bordered(),
primaryAction: .init { _ in
state += 1
label.text = "Test \(state)"
}
)
button.setTitle("+", for: .normal)
let stack = UIStackView(arrangedSubviews: [label, button])
stack.spacing = 8
stack.frame = controller.view.bounds
controller.view.addSubview(stack)
return controller
}()
}

#StorybookPage(title: "UILabel updating text") {
BookPreview { context in
let label = UILabel()
Expand Down
6 changes: 6 additions & 0 deletions Development/Demo/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ struct RootView: View {
Book.allStorybookPages()
.map({ $0.bookBody })
}

if #available(iOS 17.0, *) {
Book(title: "#Preview macro") {
Book.allBookPreviews()
}
}
}
)
)
Expand Down
4 changes: 2 additions & 2 deletions Development/Storybook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -344,7 +344,7 @@
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Demo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "f5a894bbdc3287a91c8c33f864cfb447314305f7fc66cabf1c369e8c3a67521d",
"pins" : [
{
"identity" : "descriptors",
Expand Down Expand Up @@ -32,26 +33,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-macro-testing.git",
"state" : {
"branch" : "main",
"revision" : "15916c0c328339f54c15d616465d79700e3f7de8"
"revision" : "20c1a8f3b624fb5d1503eadcaa84743050c350f4",
"version" : "0.5.2"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "e7b77228b34057041374ebef00c0fd7739d71a2b",
"version" : "1.15.3"
"revision" : "7b0bbbae90c41f848f90ac7b4df6c4f50068256d",
"version" : "1.17.5"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "64889f0c732f210a935a0ad7cda38f77f876262d",
"version" : "509.1.1"
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
},
{
Expand Down Expand Up @@ -86,19 +87,19 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/FluidGroup/TextureBridging.git",
"state" : {
"branch" : "main",
"revision" : "4383f8a9846a0507d2c22ee9fac22153f9b86fed"
"revision" : "4383f8a9846a0507d2c22ee9fac22153f9b86fed",
"version" : "3.2.1"
}
},
{
"identity" : "textureswiftsupport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/FluidGroup/TextureSwiftSupport.git",
"state" : {
"branch" : "main",
"revision" : "5bae50cab3798dccb8b98c3ffbc70320ae66b45a"
"revision" : "fb748d6a9d0a2dca0635227e1db0360fd26e0e24",
"version" : "3.20.1"
}
}
],
"version" : 2
"version" : 3
}
Loading

0 comments on commit d6b53da

Please sign in to comment.