-
Notifications
You must be signed in to change notification settings - Fork 0
Kotlin/infinitescroll views #871
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
base: kotlin/integration
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.webforj.samples.views.ininitescroll | ||
|
|
||
| import com.webforj.annotation.StyleSheet | ||
| import com.webforj.component.Composite | ||
| import com.webforj.component.html.elements.Div | ||
| import com.webforj.component.icons.FeatherIcon | ||
| import com.webforj.kotlin.dsl.component.html.elements.div | ||
| import com.webforj.kotlin.dsl.component.html.elements.span | ||
| import com.webforj.kotlin.dsl.component.icons.featherIcon | ||
| import com.webforj.kotlin.dsl.component.infiniitescroll.infiniteScroll | ||
| import com.webforj.kotlin.extension.classNames | ||
| import com.webforj.kotlin.extension.percent | ||
| import com.webforj.kotlin.extension.plus | ||
| import com.webforj.kotlin.extension.px | ||
| import com.webforj.kotlin.extension.set | ||
| import com.webforj.kotlin.extension.size | ||
| import com.webforj.kotlin.extension.styles | ||
| import com.webforj.kotlin.extension.vh | ||
| import com.webforj.router.annotation.FrameTitle | ||
| import com.webforj.router.annotation.Route | ||
|
|
||
| @Route | ||
| @FrameTitle("Fully Customized Loading") | ||
| @StyleSheet("ws://css/infinitescroll/infinitescrollcustom.css") | ||
| class InfiniteScrollCustomLoadingKotlinView: Composite<Div>() { | ||
| private val self = boundComponent | ||
|
|
||
| init { | ||
| self.apply { | ||
| height = 100.vh | ||
| styles["overflow"] = "auto" | ||
| infiniteScroll { | ||
| classNames + "is" | ||
| height = 100.percent | ||
| val canvas = div { | ||
| maxWidth = 600.px | ||
| classNames + "is-canvas" | ||
|
cliebhardt marked this conversation as resolved.
|
||
| } | ||
| div { | ||
| addClassName("custom-loading") | ||
|
cliebhardt marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
classNames += "custom-loading" |
||
| featherIcon(FeatherIcon.CLOUD) { | ||
| size = 32.px to 32.px | ||
| classNames + "loading-icon" | ||
|
cliebhardt marked this conversation as resolved.
|
||
| } | ||
| span("Loading awesome content...") | ||
| } | ||
| var index = 0 | ||
| onScroll { | ||
| if (index > 40) { | ||
| isCompleted = true | ||
| update() | ||
| return@onScroll | ||
| } | ||
|
|
||
| for (i in 0..<8) { | ||
| canvas.add(Item()) | ||
| } | ||
|
cliebhardt marked this conversation as resolved.
|
||
|
|
||
| index += 8 | ||
| update() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package com.webforj.samples.views.ininitescroll | ||
|
|
||
| import com.webforj.annotation.StyleSheet | ||
| import com.webforj.component.Composite | ||
| import com.webforj.component.html.elements.Div | ||
| import com.webforj.component.icons.FeatherIcon | ||
| import com.webforj.component.layout.flexlayout.FlexAlignment | ||
| import com.webforj.component.layout.flexlayout.FlexJustifyContent | ||
| import com.webforj.kotlin.dsl.component.html.elements.div | ||
| import com.webforj.kotlin.dsl.component.icons.featherIcon | ||
| import com.webforj.kotlin.dsl.component.infiniitescroll.infiniteScroll | ||
| import com.webforj.kotlin.dsl.component.layout.flexlayout.flexLayout | ||
| import com.webforj.kotlin.dsl.component.layout.flexlayout.horizontal | ||
| import com.webforj.kotlin.dsl.component.layout.flexlayout.vertical | ||
| import com.webforj.kotlin.extension.classNames | ||
| import com.webforj.kotlin.extension.percent | ||
| import com.webforj.kotlin.extension.plus | ||
| import com.webforj.kotlin.extension.px | ||
| import com.webforj.kotlin.extension.set | ||
| import com.webforj.kotlin.extension.styles | ||
| import com.webforj.kotlin.extension.vh | ||
| import com.webforj.router.annotation.Route | ||
| import kotlin.random.Random | ||
|
|
||
| @Route | ||
| @StyleSheet("ws://css/infinitescroll/infinitescroll.css") | ||
| class InfiniteScrollKotlinView: Composite<Div>() { | ||
| private val self = boundComponent | ||
|
|
||
| init { | ||
| self.apply { | ||
| height = 100.vh | ||
| styles["overflow"] = "auto" | ||
| infiniteScroll { | ||
| height = 100.percent | ||
| val canvas = div { | ||
| maxWidth = 600.px | ||
| classNames + "is-canvas" | ||
|
cliebhardt marked this conversation as resolved.
|
||
| } | ||
| var index = 0 | ||
| onScroll { | ||
| if (index > 40) { | ||
| isCompleted = true | ||
| update() | ||
| return@onScroll | ||
| } | ||
| for (i in 0..<8) { | ||
| canvas.add(Item()) | ||
| } | ||
|
cliebhardt marked this conversation as resolved.
|
||
| index += 8 | ||
| update() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package com.webforj.samples.views.ininitescroll | ||
|
|
||
| import com.webforj.annotation.StyleSheet | ||
| import com.webforj.component.Composite | ||
| import com.webforj.component.html.elements.Div | ||
| import com.webforj.component.icons.TablerIcon | ||
| import com.webforj.kotlin.dsl.component.html.elements.div | ||
| import com.webforj.kotlin.dsl.component.infiniitescroll.infiniteScroll | ||
| import com.webforj.kotlin.extension.classNames | ||
| import com.webforj.kotlin.extension.percent | ||
| import com.webforj.kotlin.extension.plus | ||
| import com.webforj.kotlin.extension.px | ||
| import com.webforj.kotlin.extension.set | ||
| import com.webforj.kotlin.extension.styles | ||
| import com.webforj.kotlin.extension.vh | ||
| import com.webforj.router.annotation.FrameTitle | ||
| import com.webforj.router.annotation.Route | ||
|
|
||
| @Route | ||
| @FrameTitle("Custom Loading Indicator") | ||
| @StyleSheet("ws://css/infinitescroll/infinitescroll.css") | ||
| class InfiniteScrollLoadingKotlinView: Composite<Div>() { | ||
| private val self = boundComponent | ||
|
|
||
| init { | ||
| self.apply { | ||
| height = 100.vh | ||
| styles["overflow"] = "auto" | ||
| infiniteScroll("Fetching more records...") { | ||
| classNames + "is" | ||
|
cliebhardt marked this conversation as resolved.
|
||
| height = 100.percent | ||
| val canvas = div { | ||
| maxWidth = 600.px | ||
| classNames + "is-canvas" | ||
|
cliebhardt marked this conversation as resolved.
|
||
| } | ||
| setIcon(TablerIcon.create("cloud-download")) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
icon = TablerIcon.create("cloud-download")
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| var index = 0 | ||
| onScroll { | ||
| if (index > 40) { | ||
| isCompleted = true | ||
| update() | ||
| return@onScroll | ||
| } | ||
|
|
||
| for (i in 0..<8) { | ||
| canvas.add(Item()) | ||
|
cliebhardt marked this conversation as resolved.
|
||
| } | ||
|
|
||
| index += 8 | ||
| update() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.webforj.samples.views.ininitescroll | ||
|
|
||
| import com.webforj.component.Composite | ||
| import com.webforj.component.html.elements.Div | ||
| import com.webforj.component.icons.FeatherIcon | ||
| import com.webforj.component.layout.flexlayout.FlexAlignment | ||
| import com.webforj.component.layout.flexlayout.FlexJustifyContent | ||
| import com.webforj.kotlin.dsl.component.html.elements.div | ||
| import com.webforj.kotlin.dsl.component.icons.featherIcon | ||
| import com.webforj.kotlin.dsl.component.layout.flexlayout.flexLayout | ||
| import com.webforj.kotlin.dsl.component.layout.flexlayout.horizontal | ||
| import com.webforj.kotlin.dsl.component.layout.flexlayout.vertical | ||
| import com.webforj.kotlin.extension.classNames | ||
| import com.webforj.kotlin.extension.minSize | ||
| import com.webforj.kotlin.extension.plus | ||
| import com.webforj.kotlin.extension.px | ||
| import kotlin.random.Random | ||
|
|
||
| class Item: Composite<Div>() { | ||
| private val self = boundComponent | ||
| private val random = Random.Default | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| private val names = arrayOf( | ||
| "John", "Jane", "Alice", "Bob", "Charlie", "Diana", | ||
| "Ethan", "Fiona", "George", "Hannah", "Ian", "Jill" | ||
| ); | ||
|
|
||
| init { | ||
| self.apply { | ||
| flexLayout { | ||
| horizontal() | ||
| justifyContent = FlexJustifyContent.BETWEEN | ||
| alignment = FlexAlignment.CENTER | ||
| flexLayout { | ||
| vertical() | ||
| div(names.random()) { | ||
| classNames + "item-name" | ||
| } | ||
| div { | ||
| classNames + "item-excerpt" | ||
| text = ("Lorem ipsum dolor sit amet, consectetur adipiscing elit. " | ||
| + "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. String concatenation with text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." |
||
| } | ||
| } | ||
| featherIcon(FeatherIcon.ARROW_RIGHT) { | ||
| minSize = 24.px to 24.px | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.