Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
feat: update beagle sample (#429)
Browse files Browse the repository at this point in the history
* created screen context

* Synced Micronaut BFF sample to Spring BFF sample.

* upadte screen context

* change screen context

* style screen context

* screen context flex updated

* update

* update send request screen context

* change screen button and text

* change screen platform and customPlatform

* change screen image remote

* change constants

* change style textField

* created screen safe area

* Synced Micronaut BFF sample to Spring BFF sample.

* change screen safe area

* created style text-input and change name services and controller image

* Synced Spring BFF sample to Micronaut BFF sample.

* Synced Micronaut BFF sample to Spring BFF sample.

* translation screen context

* created screen text input

* Synced Micronaut BFF sample to Spring BFF sample.

* change color text and add padding

* change screen image

* remove wildcard import

* Synced Micronaut BFF sample to Spring BFF sample.

* Synced Spring BFF sample to Micronaut BFF sample.

* very large method correction

* change style text-network-image to text-image-remote

* change style button parent

* Synced Spring BFF sample to Micronaut BFF sample.

Signed-off-by: runner <[email protected]>

Co-authored-by: Luis Gustavo <[email protected]>
Co-authored-by: Matheus Ribeiro <[email protected]>
Co-authored-by: runner <[email protected]>
  • Loading branch information
4 people authored Jul 13, 2020
1 parent 5ca1016 commit d99fc70
Show file tree
Hide file tree
Showing 29 changed files with 775 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ class AppDesignSystem : DesignSystem() {
"DesignSystem.Text.H3" -> R.style.DesignSystem_Text_H3
"DesignSystem.Text.Action.Click" -> R.style.DesignSystem_Text_Action_Click
"DesignSystem.Text.helloWord" -> R.style.DesignSystem_Text_helloWord
"DesignSystem.Text.Image.Remote" -> R.style.DesignSystem_Text_Image_Remote
else -> R.style.DesignSystem_Text_Default
}
}

override fun inputTextStyle(id: String): Int? {
return when(id) {
"TextInput" -> R.style.TextInput
"DesignSystem.TextInput.Style.Bff" -> R.style.DesignSystem_TextInput_Style_Bff
else -> null
}
}
Expand Down
27 changes: 27 additions & 0 deletions android/sample/src/main/res/drawable/text_input_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
~
~ 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.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>
<padding android:left="10dp"/>

<stroke
android:width="3dp"
android:color="#808080"/>
<corners
android:radius="5dp"/>
</shape>
16 changes: 12 additions & 4 deletions android/sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorHint">@color/colorGray</item>
<item name="android:scrollbarThumbVertical">@color/colorGray</item>
<item name="android:scrollbarThumbHorizontal">@color/colorGray</item>
<item name="android:windowBackground">@color/colorWhite</item>
<item name="colorControlNormal">@color/colorWhite</item>
</style>
Expand Down Expand Up @@ -99,6 +102,11 @@
<item name="android:textColorHint">@color/colorGreen</item>
</style>

<style name="DesignSystem.TextInput.Style.Bff" parent="Widget.AppCompat.EditText">
<item name="android:textColor">@color/colorBlack</item>
<item name="background">@drawable/text_input_background</item>
</style>

<style name="DesignSystem.Text.H2" parent="DesignSystem.Text.Default">
<item name="android:textSize">20sp</item>
</style>
Expand All @@ -113,21 +121,21 @@
<item name="android:textStyle">bold</item>
</style>

<style name="DesignSystem.Text.NetworkImage" parent="DesignSystem.Text.Default">
<style name="DesignSystem.Text.Image.Remote" parent="DesignSystem.Text.Default">
<item name="android:textSize">14sp</item>
<item name="android:textColor">@android:color/black</item>
</style>

<style name="DesignSystem.Button.Style" parent="DesignSystem.Text.Default">
<style name="DesignSystem.Button.Style" parent="Widget.AppCompat.Button">
<item name="android:textColor">@color/colorBlack</item>
</style>

<style name="DesignSystem.Stylish.Button" parent="DesignSystem.Text.Default">
<style name="DesignSystem.Stylish.Button" parent="Widget.AppCompat.Button">
<item name="android:textColor">@color/colorGray</item>
<item name="background">@android:color/transparent</item>
</style>

<style name="DesignSystem.Stylish.ButtonAndAppearance" parent="DesignSystem.Text.Default">
<style name="DesignSystem.Stylish.ButtonAndAppearance" parent="Widget.AppCompat.Button">
<item name="android:textColor">@color/colorWhite</item>
<item name="android:textStyle">bold</item>
</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,14 @@ object ButtonScreenBuilder : ScreenBuilder {
text = text,
styleId = styleId,
style = Style(
backgroundColor = CYAN_BLUE,
cornerRadius = CornerRadius(radius = 16.0),
margin = EdgeValue(
left = 25.unitReal(),
right = 25.unitReal(),
top = 15.unitReal()
)
)
).applyStyle(
Style(
backgroundColor = CYAN_BLUE,
cornerRadius = CornerRadius(radius = 16.0)
)
)

private fun createButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ import br.com.zup.beagle.sample.constants.SCREEN_BFF_NETWORK_IMAGE_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_BUILDER_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_BUTTON_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_COMPOSE_COMPONENT_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_CONTEXT_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_FORM_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_IMAGE_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_LAZY_COMPONENT_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_LIST_VIEW_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_NAVIGATION_BAR_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_NETWORK_IMAGE_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_PAGE_VIEW_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_SAFE_AREA_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_SCROLL_VIEW_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_TAB_VIEW_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_TEXT_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_TEXT_INPUT_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_TOUCHABLE_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_WEB_VIEW_ENDPOINT
import br.com.zup.beagle.widget.action.Navigate
Expand Down Expand Up @@ -82,7 +85,10 @@ object ComponentScreenBuilder : ScreenBuilder {
createMenu("Analytics", SCREEN_ANALYTICS_ENDPOINT),
createMenu("Web View", SCREEN_WEB_VIEW_ENDPOINT),
createMenu("Platform", PLATFORM_SAMPLE_ENDPOINT),
createMenu("Custom Platform", CUSTOM_PLATFORM_SAMPLE_ENDPOINT)
createMenu("Custom Platform", CUSTOM_PLATFORM_SAMPLE_ENDPOINT),
createMenu("Context", SCREEN_CONTEXT_ENDPOINT),
createMenu("Safe Area", SCREEN_SAFE_AREA_ENDPOINT),
createMenu("Text Input", SCREEN_TEXT_INPUT_ENDPOINT)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ package br.com.zup.beagle.sample.builder

import br.com.zup.beagle.core.ServerDrivenComponent
import br.com.zup.beagle.platform.BeaglePlatform
import br.com.zup.beagle.widget.layout.NavigationBar
import br.com.zup.beagle.widget.layout.Screen
import br.com.zup.beagle.widget.layout.ScreenBuilder
import br.com.zup.beagle.widget.layout.ScrollView
import br.com.zup.beagle.widget.ui.Text

class CustomPlatformBuilder(private val beaglePlatform: BeaglePlatform) : ScreenBuilder {
override fun build() = Screen(
navigationBar = NavigationBar(
title = "Beagle Tab View",
showBackButton = true
),
child = createComponentUsingBeaglePlatform()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package br.com.zup.beagle.sample.builder

import br.com.zup.beagle.ext.applyFlex
import br.com.zup.beagle.widget.action.Alert
import br.com.zup.beagle.sample.constants.LOGO_BEAGLE
import br.com.zup.beagle.sample.constants.TITLE_SCREEN
import br.com.zup.beagle.widget.core.AlignSelf
import br.com.zup.beagle.widget.core.Flex
import br.com.zup.beagle.widget.core.ImageContentMode
import br.com.zup.beagle.widget.core.ScrollAxis
import br.com.zup.beagle.widget.layout.NavigationBar
Expand All @@ -30,7 +33,7 @@ import br.com.zup.beagle.widget.ui.Image
import br.com.zup.beagle.widget.ui.ImagePath.Local
import br.com.zup.beagle.widget.ui.Text

object ImageScreenBuilder : ScreenBuilder {
object ImageLocalScreenBuilder : ScreenBuilder {
override fun build() = Screen(
navigationBar = NavigationBar(
title = "Beagle Image",
Expand All @@ -50,13 +53,18 @@ object ImageScreenBuilder : ScreenBuilder {
),
child = ScrollView(
scrollDirection = ScrollAxis.VERTICAL,
children = listOf(createText("Image"), Image(Local.justMobile(LOGO_BEAGLE))) +
children = listOf(
createText("Image").applyFlex(Flex(alignSelf = AlignSelf.CENTER)),
Image(Local.justMobile(LOGO_BEAGLE))) +
ImageContentMode.values().flatMap(this::createImageWithModeAndText)
)
)

private fun createText(text: String) = Text(text = text, styleId = TITLE_SCREEN)

private fun createImageWithModeAndText(mode: ImageContentMode) =
listOf(createText("Image with contentMode = $mode"), Image(Local.justMobile(LOGO_BEAGLE), mode))
listOf(
createText("Image with Mode = $mode").applyFlex(Flex(alignSelf = AlignSelf.CENTER)),
Image(Local.justMobile(LOGO_BEAGLE), mode)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package br.com.zup.beagle.sample.builder

import br.com.zup.beagle.core.Style
import br.com.zup.beagle.widget.action.Alert
import br.com.zup.beagle.ext.applyStyle
import br.com.zup.beagle.ext.unitReal
import br.com.zup.beagle.sample.constants.TEXT_NETWORK_IMAGE
import br.com.zup.beagle.widget.action.Alert
import br.com.zup.beagle.sample.constants.TEXT_IMAGE_REMOTE
import br.com.zup.beagle.widget.core.AlignSelf
import br.com.zup.beagle.widget.core.EdgeValue
import br.com.zup.beagle.widget.core.Flex
Expand All @@ -38,18 +38,18 @@ import br.com.zup.beagle.widget.ui.ImagePath.Local
import br.com.zup.beagle.widget.ui.ImagePath.Remote
import br.com.zup.beagle.widget.ui.Text

class NetworkImageScreenBuilder(private val imagePath: String) : ScreenBuilder {
class ImageRemoteScreenBuilder(private val imagePath: String) : ScreenBuilder {

override fun build() = Screen(
navigationBar = NavigationBar(
title = "Beagle NetworkImage",
title = "Beagle Image Remote",
showBackButton = true,
navigationBarItems = listOf(
NavigationBarItem(
text = "",
image = Local.justMobile("informationImage"),
action = Alert(
title = "NetworkImage",
title = "Image Remote",
message = "It is a widget that implements an image with a URL.",
labelOk = "OK"
)
Expand All @@ -58,8 +58,8 @@ class NetworkImageScreenBuilder(private val imagePath: String) : ScreenBuilder {
),
child = ScrollView(
scrollDirection = ScrollAxis.VERTICAL,
children = listOf(buildImage(title = "NetworkImage")) +
ImageContentMode.values().map { buildImage("NetworkImage with ImageContentMode.$it", it) }
children = listOf(buildImage(title = "Image Remote")) +
ImageContentMode.values().map { buildImage("Image Remote with Mode.$it", it) }
)
)

Expand All @@ -80,7 +80,7 @@ class NetworkImageScreenBuilder(private val imagePath: String) : ScreenBuilder {

private fun buildText(text: String) = Text(
text = text,
styleId = TEXT_NETWORK_IMAGE
styleId = TEXT_IMAGE_REMOTE
).applyStyle(Style(
flex = Flex(
alignSelf = AlignSelf.CENTER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ package br.com.zup.beagle.sample.builder
import br.com.zup.beagle.platform.BeaglePlatform
import br.com.zup.beagle.platform.forPlatform
import br.com.zup.beagle.widget.layout.Container
import br.com.zup.beagle.widget.layout.NavigationBar
import br.com.zup.beagle.widget.layout.Screen
import br.com.zup.beagle.widget.layout.ScreenBuilder
import br.com.zup.beagle.widget.ui.Button

object PlatformBuilder : ScreenBuilder {
override fun build() = Screen(
navigationBar = NavigationBar(
title = "Beagle Tab View",
showBackButton = true
),
child = Container(
listOf(
Button(text = "mobile only text").forPlatform(BeaglePlatform.MOBILE),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright 2020 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
*
* 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.
*/

package br.com.zup.beagle.sample.builder

import br.com.zup.beagle.core.Style
import br.com.zup.beagle.ext.applyStyle
import br.com.zup.beagle.ext.unitReal
import br.com.zup.beagle.sample.constants.LOGO_BEAGLE
import br.com.zup.beagle.sample.constants.SCREEN_SAFE_AREA_FALSE_ENDPOINT
import br.com.zup.beagle.sample.constants.SCREEN_SAFE_AREA_TRUE_ENDPOINT
import br.com.zup.beagle.widget.action.Alert
import br.com.zup.beagle.widget.action.Navigate
import br.com.zup.beagle.widget.action.Route
import br.com.zup.beagle.widget.core.AlignItems
import br.com.zup.beagle.widget.core.AlignSelf
import br.com.zup.beagle.widget.core.EdgeValue
import br.com.zup.beagle.widget.core.Flex
import br.com.zup.beagle.widget.layout.Container
import br.com.zup.beagle.widget.layout.NavigationBar
import br.com.zup.beagle.widget.layout.SafeArea
import br.com.zup.beagle.widget.layout.Screen
import br.com.zup.beagle.widget.layout.ScreenBuilder
import br.com.zup.beagle.widget.ui.Button
import br.com.zup.beagle.widget.ui.Image
import br.com.zup.beagle.widget.ui.ImagePath
import br.com.zup.beagle.widget.ui.Text

object SafeAreaBuilder: ScreenBuilder {
override fun build() = Screen(
navigationBar = NavigationBar(
title = "Beagle Safe Area",
showBackButton = true
),
child = Container(
listOf(
Button(
text = "Safe Area True",
onPress = listOf(
Navigate.PushView(Route.Remote(SCREEN_SAFE_AREA_TRUE_ENDPOINT)),
Alert(
title = "Attention",
message = "This functionality works only on some iPhones models!"
)
)

),
Button(
text = "Safe Area False",
onPress = listOf(Navigate.PushView(Route.Remote(SCREEN_SAFE_AREA_FALSE_ENDPOINT)))

)
)
)
)

fun createScreen(safeArea: Boolean): Screen = Screen(
navigationBar = NavigationBar(
title = "Beagle Safe Area",
showBackButton = true
),
child = Container(
listOf(
Text("Safe area $safeArea").applyStyle(
Style(
margin = EdgeValue(top = 100.unitReal()),
flex = Flex(
alignSelf = AlignSelf.CENTER
)
)
),
Image(ImagePath.Local.justMobile(LOGO_BEAGLE)).applyStyle(
Style(
margin = EdgeValue(top = 100.unitReal())
)
)
)
).applyStyle(
Style(
backgroundColor = "#b7efcd",
flex = Flex(
grow = 1.0,
alignItems = AlignItems.CENTER
)
)
),
safeArea = SafeArea(
top = safeArea,
bottom = safeArea,
leading = safeArea,
trailing = safeArea
)
)
}
Loading

0 comments on commit d99fc70

Please sign in to comment.