Skip to content

Commit

Permalink
Merge branch 'main' of github.com:lightningkite/rock
Browse files Browse the repository at this point in the history
  • Loading branch information
WesleyEdwards committed Mar 12, 2024
2 parents d53c324 + 2292f95 commit 5cbb5ef
Show file tree
Hide file tree
Showing 48 changed files with 1,750 additions and 423 deletions.
7 changes: 7 additions & 0 deletions example-app-ios/Rock Example App/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
PlatformSpecificScreen_iosKt.makeMeAGradient = {
let layer = CAGradientLayer()
layer.colors = [UIColor.red.cgColor, UIColor.blue.cgColor]
layer.locations = [0, 1]
layer.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
return layer
}
RootSetupIosKt.setup(self, app: { $0.app() })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ val appTheme = Property<Theme>(
secondary = Color.blue,
title = FontAndStyle(font = Resources.fontsMontserrat),
body = FontAndStyle(font = Resources.fontsMontserrat),
spacing = 1.5.rem,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,27 @@ object ControlsScreen : RockScreen {
col {

h1 { content = "Controls" } in padded in hasPopover {
text {
content = "Pop over!"
} in card
card - col {
text {
content = "Pop over!"
}
button {
text("Dismiss")
onClick {
it.close()
}
}
}
}
card - col {
h2 { content = "Buttons" }
row {
expanding - space {}
centered - important - compact - compact - button {
icon {
source = Icon.star
}
}
button { onClick { delay(1000L) }; text { content = "Sample" }; ::enabled { booleanContent.await() } }
card - button { onClick { delay(1000L) }; text { content = "Card" }; ::enabled { booleanContent.await() } }
important - button { onClick { delay(1000L) }; text { content = "Important" }; ::enabled { booleanContent.await() } }
Expand Down Expand Up @@ -232,13 +245,27 @@ object ControlsScreen : RockScreen {
col {
h2 { content = "Images" }
row {
repeat(5) {
image { source = ImageRemote("https://picsum.photos/seed/${it}/200/300") } in sizedBox(
image { source = ImageRemote("https://picsum.photos/seed/0/200/300") } in sizedBox(
SizeConstraints(
width = 5.rem
)
)
stack {
image { source = ImageRemote("https://picsum.photos/seed/1/200/300") } in sizedBox(
SizeConstraints(
width = 5.rem
)
)
}
padded - stack {
spacing = 0.px
image { source = ImageRemote("https://picsum.photos/seed/2/200/300") } in sizedBox(
SizeConstraints(
width = 5.rem
)
)
}

} in scrollsHorizontally
} in card
} in scrolls
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.lightningkite.mppexampleapp

import com.lightningkite.rock.*
import com.lightningkite.rock.models.*
import com.lightningkite.rock.navigation.RockScreen
import com.lightningkite.rock.reactive.*
import com.lightningkite.rock.views.*
import com.lightningkite.rock.views.direct.*
import com.lightningkite.rock.views.l2.lazyExpanding

@Routable("recycler-view-infinite-images")
object InfiniteImagesScreen : RockScreen {
override val title: Readable<String>
get() = super.title

object ReturnIndexList: List<Int>{
override val size: Int
get() = Int.MAX_VALUE
override fun get(index: Int): Int = index
override fun isEmpty(): Boolean = false
override fun iterator(): Iterator<Int> = (0..<Int.MAX_VALUE).iterator()
override fun listIterator(): ListIterator<Int> = object: ListIterator<Int> {
var n = -1
override fun hasNext(): Boolean = n < Int.MAX_VALUE
override fun hasPrevious(): Boolean = n > 0
override fun next(): Int = ++n
override fun nextIndex(): Int = ++n
override fun previous(): Int = --n
override fun previousIndex(): Int = --n
}
override fun listIterator(index: Int): ListIterator<Int> = object: ListIterator<Int> {
var n = index - 1
override fun hasNext(): Boolean = n < Int.MAX_VALUE
override fun hasPrevious(): Boolean = n > 0
override fun next(): Int = ++n
override fun nextIndex(): Int = ++n
override fun previous(): Int = --n
override fun previousIndex(): Int = --n
}
override fun subList(fromIndex: Int, toIndex: Int): List<Int> = (fromIndex..<toIndex).toList()
override fun lastIndexOf(element: Int): Int = element
override fun indexOf(element: Int): Int = element
override fun containsAll(elements: Collection<Int>): Boolean = true
override fun contains(element: Int): Boolean = true
}

override fun ViewWriter.render() {
recyclerView {
columns = 4
children(Constant(ReturnIndexList)) {
stack {
sizeConstraints(height = 16.rem) - image {
scaleType = ImageScaleType.Crop
::source { ImageRemote("https://picsum.photos/seed/${it.await()}/200/200") }
// source = Resources.imagesSolera
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ object RootScreen : RockScreen {
}
} in card

linkScreen(InfiniteImagesScreen)
linkScreen(PlatformSpecificScreen)
linkScreen(VideoElementScreen)
linkScreen(ViewPagerElementScreen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,40 @@ object VectorsTestScreen : RockScreen {
4.rem, 4.rem,
viewBoxWidth = 100,
viewBoxHeight = 100,
paths = listOf(ImageVector.Path(
strokeColor = Color.black,
strokeWidth = 4.0,
path = "M 20 50 A 60 60 0 0 0 80 50"
), ImageVector.Path(
strokeColor = Color.blue,
strokeWidth = 2.0,
path = "M 50 0 V 100"
))
paths = listOf(
ImageVector.Path(
strokeColor = Color.black,
strokeWidth = 4.0,
path = "M 20 50 A 60 60 0 0 0 80 50"
), ImageVector.Path(
strokeColor = Color.blue,
strokeWidth = 2.0,
path = "M 50 0 V 100"
)
)
)
}
image {
source = ImageVector(
4.rem, 4.rem,
viewBoxWidth = 320,
viewBoxHeight = 320,
paths = listOf(ImageVector.Path(
strokeColor = Color.black,
strokeWidth = 10.0,
path = "M 10 315\n" +
" L 110 215\n" +
" A 30 50 0 0 1 162.55 162.45\n" +
" L 172.55 152.45\n" +
" A 30 50 -45 0 1 215.1 109.9\n" +
" L 315 10"
))
paths = listOf(
ImageVector.Path(
strokeColor = Color.black,
strokeWidth = 10.0,
path = "M 10 315\n" +
" L 110 215\n" +
" A 30 50 0 0 1 162.55 162.45\n" +
" L 172.55 152.45\n" +
" A 30 50 -45 0 1 215.1 109.9\n" +
" L 315 10"
)
)
)
}
}
row {
image {
source = ImageVector(
4.rem,
Expand Down Expand Up @@ -150,7 +156,7 @@ object VectorsTestScreen : RockScreen {
)
}
}
row {
row {
image {
source = ImageVector(
4.rem,
Expand All @@ -159,12 +165,19 @@ object VectorsTestScreen : RockScreen {
viewBoxHeight = 100,
paths = listOf(
ImageVector.Path(
fillColor = LinearGradient(listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.eighthTurn, false),
fillColor = LinearGradient(
listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.zero, false
),
path = "M 0,0 L 0,100 L 100,100 L 100,0 Z"
),
ImageVector.Path(
strokeColor = Color.black,
strokeWidth = 5.0,
path = "M0,0L100,100"
),
)
)
}
Expand All @@ -176,15 +189,78 @@ object VectorsTestScreen : RockScreen {
viewBoxHeight = 100,
paths = listOf(
ImageVector.Path(
fillColor = LinearGradient(listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.eighthTurn + Angle.halfTurn, false),
fillColor = LinearGradient(
listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.eighthTurn, false
),
path = "M 0,0 L 0,100 L 100,100 L 100,0 Z"
),
ImageVector.Path(
strokeColor = Color.black,
strokeWidth = 5.0,
path = "M0,0L100,100"
),
)
)
}
image {
source = ImageVector(
4.rem,
4.rem,
viewBoxWidth = 100,
viewBoxHeight = 100,
paths = listOf(
ImageVector.Path(
fillColor = LinearGradient(
listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.eighthTurn + Angle.halfTurn, false
),
path = "M 0,0 L 0,100 L 100,100 L 100,0 Z"
),
ImageVector.Path(
strokeColor = Color.black,
strokeWidth = 5.0,
path = "M0,0L100,100"
),
)
)
}
}
row {
sizeConstraints(width = 4.rem, height = 4.rem) - themeFromLast {
it.copy(
background = LinearGradient(
listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.zero, false
)
)
} - stack { space() }
sizeConstraints(width = 4.rem, height = 4.rem) - themeFromLast {
it.copy(
background = LinearGradient(
listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.eighthTurn, false
)
)
} - stack { space() }
sizeConstraints(width = 4.rem, height = 4.rem) - themeFromLast {
it.copy(
background = LinearGradient(
listOf(
GradientStop(0f, Color.blue),
GradientStop(1f, Color.red),
), Angle.eighthTurn + Angle.halfTurn, false
)
)
} - stack { space() }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ object DataScreen: DocScreen {
override fun ViewWriter.render() {
article {
h1("Data")
text("Rock is roughly based on Solid.js, which uses smaller blocks to contain actions that should run when dependencies change.")
text("Rock is roughly based on Solid.js, which uses smaller blocks to contain actions that should run when dependencies change.\nHowever, to begin using that, we have to first look at Property.")

text("However, to begin using that, we have to first look at Property.")
code - text("val counter = Property<Int>(0)")
val counter = Property<Int>(0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ interface DocScreen: RockScreen {
val covers: List<String>
}

val ViewWriter.code: ViewWrapper get() = tweakTheme {
val ViewWriter.code: ViewWrapper get() = themeFromLast {
it.copy(body = FontAndStyle(font = systemDefaultFixedWidthFont))
}

fun ViewWriter.example(
codeText: String,
action: ViewWriter.()->Unit
) {
card - row {
row {
expanding - scrollsHorizontally - code - text(codeText)
separator()
expanding - action()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ object DocSearchScreen : RockScreen {
expanding - recyclerView {
children(shared {
listOf(
TextElementScreen,
DataScreen,
NavigationScreen,
VideoElementScreen,
ViewPagerElementScreen,
ImageElementScreen,
IconsScreen
IconsScreen,
ViewModifiersScreen,
LayoutScreen
).mapNotNull {
val q = query.await()
if(q.isBlank()) return@mapNotNull it to it.covers
Expand Down
Loading

0 comments on commit 5cbb5ef

Please sign in to comment.