diff --git a/android/sample/src/main/java/br/com/zup/beagle/sample/AppDesignSystem.kt b/android/sample/src/main/java/br/com/zup/beagle/sample/AppDesignSystem.kt index 2ea14ab2ae..a9b9f404d5 100644 --- a/android/sample/src/main/java/br/com/zup/beagle/sample/AppDesignSystem.kt +++ b/android/sample/src/main/java/br/com/zup/beagle/sample/AppDesignSystem.kt @@ -49,6 +49,7 @@ 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 } } @@ -56,6 +57,7 @@ class AppDesignSystem : DesignSystem() { 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 } } diff --git a/android/sample/src/main/res/drawable/text_input_background.xml b/android/sample/src/main/res/drawable/text_input_background.xml new file mode 100644 index 0000000000..cb5cb1dd6f --- /dev/null +++ b/android/sample/src/main/res/drawable/text_input_background.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/android/sample/src/main/res/values/styles.xml b/android/sample/src/main/res/values/styles.xml index 7f6897f602..b0f427c04a 100644 --- a/android/sample/src/main/res/values/styles.xml +++ b/android/sample/src/main/res/values/styles.xml @@ -26,6 +26,9 @@ @color/colorPrimary @color/colorPrimaryDark @color/colorAccent + @color/colorGray + @color/colorGray + @color/colorGray @color/colorWhite @color/colorWhite @@ -99,6 +102,11 @@ @color/colorGreen + + @@ -113,21 +121,21 @@ bold - - - - diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ButtonScreenBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ButtonScreenBuilder.kt index b39a9e2549..593a985248 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ButtonScreenBuilder.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ButtonScreenBuilder.kt @@ -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( diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ComponentScreenBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ComponentScreenBuilder.kt index c4dd538244..4bb52f7145 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ComponentScreenBuilder.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ComponentScreenBuilder.kt @@ -30,6 +30,7 @@ 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 @@ -37,9 +38,11 @@ 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 @@ -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) ) ) ) diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/CustomPlatformBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/CustomPlatformBuilder.kt index 67213d09ec..ad6bcde7d2 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/CustomPlatformBuilder.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/CustomPlatformBuilder.kt @@ -18,6 +18,7 @@ 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 @@ -25,6 +26,10 @@ 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() ) diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageScreenBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageLocalScreenBuilder.kt similarity index 81% rename from backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageScreenBuilder.kt rename to backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageLocalScreenBuilder.kt index d278db0da5..d067b9253f 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageScreenBuilder.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageLocalScreenBuilder.kt @@ -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 @@ -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", @@ -50,7 +53,9 @@ 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) ) ) @@ -58,5 +63,8 @@ object ImageScreenBuilder : ScreenBuilder { 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) + ) } diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/NetworkImageScreenBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageRemoteScreenBuilder.kt similarity index 86% rename from backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/NetworkImageScreenBuilder.kt rename to backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageRemoteScreenBuilder.kt index c3880e005f..e8209cc6a4 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/NetworkImageScreenBuilder.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ImageRemoteScreenBuilder.kt @@ -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 @@ -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" ) @@ -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) } ) ) @@ -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 diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/PlatformBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/PlatformBuilder.kt index f7b244df1a..3b79141f74 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/PlatformBuilder.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/PlatformBuilder.kt @@ -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), diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/SafeAreaBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/SafeAreaBuilder.kt new file mode 100644 index 0000000000..49be72d722 --- /dev/null +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/SafeAreaBuilder.kt @@ -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 + ) + ) +} \ No newline at end of file diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ScreenContextBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ScreenContextBuilder.kt new file mode 100644 index 0000000000..a99f9455ca --- /dev/null +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/ScreenContextBuilder.kt @@ -0,0 +1,246 @@ +/* + * 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.CornerRadius +import br.com.zup.beagle.core.Style +import br.com.zup.beagle.ext.applyFlex +import br.com.zup.beagle.ext.applyStyle +import br.com.zup.beagle.ext.unitPercent +import br.com.zup.beagle.ext.unitReal +import br.com.zup.beagle.widget.action.Alert +import br.com.zup.beagle.widget.action.Confirm +import br.com.zup.beagle.widget.action.RequestActionMethod +import br.com.zup.beagle.widget.action.SendRequest +import br.com.zup.beagle.widget.action.SetContext +import br.com.zup.beagle.widget.context.ContextData +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.core.Size +import br.com.zup.beagle.widget.core.TextInputType +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.layout.ScrollView +import br.com.zup.beagle.widget.ui.Button +import br.com.zup.beagle.widget.ui.Text +import br.com.zup.beagle.widget.ui.TextInput + +data class Address(val data: Data) + +data class Data( + val zip: String, + val street: String, + val number: String, + val neighborhood: String, + val city: String, + val state: String, + val complement: String +) + +object ScreenContextBuilder : ScreenBuilder { + var styleMargin = Style( + margin = EdgeValue( + top = 10.unitReal(), + left = 25.unitReal(), + right = 25.unitReal() + ) + ) + + override fun build() = Screen( + navigationBar = NavigationBar( + title = "Beagle Context", + showBackButton = true + ), + child = Container( + children = listOf( + ScrollView( + children = listOf( + Text( + text = "Fill the form", + styleId = "DesignSystem.Text.helloWord" + ).applyStyle( + Style( + margin = EdgeValue(top = 20.unitReal(), bottom = 20.unitReal()), + flex = Flex( + alignSelf = AlignSelf.CENTER + ) + ) + ), + createZip(), + createTextInput(), + createButton() + ), + context = ContextData( + id = "address", + value = Address( + data = Data( + zip = "", + street = "", + number = "", + neighborhood = "", + city = "", + state = "", + complement = "" + ) + ) + ) + ) + ) + ).applyFlex(Flex(grow = 1.0)) + ) + + private fun createTextInput() = Container( + children = listOf( + createTextInput( + textInputPlaceholder = "Street", + textInputValue = "@{address.data.street}", + contextPath = "data.street" + ), + createTextInput( + textInputPlaceholder = "Number", + textInputValue = "@{address.data.number}", + contextPath = "data.number", + type = TextInputType.NUMBER + ), + createTextInput( + textInputPlaceholder = "Neighborhood", + textInputValue = "@{address.data.neighborhood}", + contextPath = "data.neighborhood" + ), + createTextInput( + textInputPlaceholder = "City", + textInputValue = "@{address.data.city}", + contextPath = "data.city" + ), + createTextInput( + textInputPlaceholder = "State", + textInputValue = "@{address.data.state}", + contextPath = "data.state" + ), + createTextInput( + textInputPlaceholder = "Complement", + textInputValue = "@{address.data.complement}", + contextPath = "data.complement" + ) + ) + ) + + private fun createZip() = TextInput( + placeholder = "ZIP", + value = "@{address.data.zip}", + styleId = "DesignSystem.TextInput.Style.Bff", + type = TextInputType.NUMBER, + onChange = listOf( + SetContext( + contextId = "address", + path = "data.zip", + value = "@{onChange.value}" + ) + ), + onBlur = listOf( + SendRequest( + url = "https://viacep.com.br/ws/@{onBlur.value}/json", + method = RequestActionMethod.GET, + onSuccess = listOf( + SetContext( + contextId = "address", + path = "data", + value = Data( + zip = "@{onBlur.value}", + street = "@{onSuccess.data.logradouro}", + number = "@{address.data.number}", + neighborhood = "@{onSuccess.data.bairro}", + city = "@{onSuccess.data.localidade}", + state = "@{onSuccess.data.uf}", + complement = "@{address.data.complement}" + ) + ) + ) + ) + ) + ).applyStyle(styleMargin) + + + private fun createButton() = Button( + text = "Enviar", + styleId = "DesignSystem.Button.Context", + onPress = listOf( + Confirm( + title = "Address form!", + message = "The data is correct?\n" + + "Street: @{address.data.street}\n" + + "Number: @{address.data.number}\n" + + "Neighborhood: @{address.data.neighborhood}\n" + + "City: @{address.data.city}\n" + + "State: @{address.data.state}\n" + + "Complement: @{address.data.complement}", + onPressOk = Alert( + title = "Address form", + message = "The form was successfully!", + onPressOk = SetContext( + contextId = "address", + path = "data", + value = + Data( + zip = "", + street = "", + number = "", + neighborhood = "", + city = "", + state = "", + complement = "" + ) + ) + ) + ) + ) + ).applyStyle( + Style( + backgroundColor = "#808080", + cornerRadius = CornerRadius(8.0), + size = Size(width = 50.unitPercent()), + margin = EdgeValue( + top = 30.unitReal() + ), + flex = Flex( + alignSelf = AlignSelf.CENTER + ) + ) + ) + + private fun createTextInput( + textInputPlaceholder: String, + textInputValue: String, + contextPath: String, + type: TextInputType? = null + ): TextInput = TextInput( + placeholder = textInputPlaceholder, + value = textInputValue, + type = type, + styleId = "DesignSystem.TextInput.Style.Bff", + onChange = listOf( + SetContext( + contextId = "address", + path = contextPath, + value = "@{onChange.value}" + ) + ) + ).applyStyle(styleMargin) +} diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/TextInputBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/TextInputBuilder.kt new file mode 100644 index 0000000000..836bd5a013 --- /dev/null +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/TextInputBuilder.kt @@ -0,0 +1,70 @@ +/* + * 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.widget.action.Alert +import br.com.zup.beagle.widget.core.EdgeValue +import br.com.zup.beagle.widget.layout.Container +import br.com.zup.beagle.widget.layout.NavigationBar +import br.com.zup.beagle.widget.layout.NavigationBarItem +import br.com.zup.beagle.widget.layout.Screen +import br.com.zup.beagle.widget.layout.ScreenBuilder +import br.com.zup.beagle.widget.ui.ImagePath +import br.com.zup.beagle.widget.ui.Text +import br.com.zup.beagle.widget.ui.TextInput + +object TextInputBuilder: ScreenBuilder { + val styleTextInput = Style(margin = EdgeValue(top = 10.unitReal(),left = 25.unitReal(),right = 25.unitReal())) + + override fun build() = Screen( + navigationBar = NavigationBar( + title = "Beagle Text Input", + showBackButton = true, + navigationBarItems = listOf( + NavigationBarItem( + text = "", + image = ImagePath.Local.justMobile("informationImage"), + action = Alert( + title = "Text Input", + message = "This widget will define a Text Input view natively using the server driven " + + "information received through Beagle.", + labelOk = "OK" + ) + ) + ) + ), + child = Container( + listOf( + createTextInput("Text Input without style!"), + createTextInput("Text Input with style!", "DesignSystem.TextInput.Style.Bff") + ) + ) + ) + + private fun createTextInput(text: String, styleId: String? = null) = Container( + listOf( + Text(text).applyStyle(styleTextInput), + TextInput( + placeholder = "Your text", + styleId = styleId + ).applyStyle(styleTextInput) + ) + ) +} \ No newline at end of file diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/TextScreenBuilder.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/TextScreenBuilder.kt index 277141ed5f..8a0e5c3304 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/TextScreenBuilder.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/builder/TextScreenBuilder.kt @@ -67,15 +67,15 @@ object TextScreenBuilder : ScreenBuilder { text: String, styleId: String? = null, appearanceColor: String? = null - ) = Text(text = text, styleId = styleId) - .applyStyle( - style = Style( - margin = EdgeValue( - top = 16.unitReal(), - left = 16.unitReal(), - right = 16.unitReal() - ), - backgroundColor = appearanceColor + ) = + Text(text = text, styleId = styleId) + .applyStyle(Style( + backgroundColor = appearanceColor, + margin = EdgeValue( + top = 16.unitReal(), + left = 16.unitReal(), + right = 16.unitReal() + ) + ) ) - ) } diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/PathConstants.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/PathConstants.kt index e30d6ebf2a..1322e0f812 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/PathConstants.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/PathConstants.kt @@ -53,6 +53,11 @@ const val SCREEN_TOUCHABLE_ENDPOINT = "/touchable" const val SCREEN_EXAMPLE_ENDPOINT = "/navigate-example" const val SCREEN_ACTION_CLICK_ENDPOINT = "/action-click" const val SCREEN_WEB_VIEW_ENDPOINT = "/web-view" +const val SCREEN_CONTEXT_ENDPOINT = "/context" +const val SCREEN_SAFE_AREA_ENDPOINT = "/safe-area" +const val SCREEN_SAFE_AREA_TRUE_ENDPOINT = "/safe-area/true" +const val SCREEN_SAFE_AREA_FALSE_ENDPOINT = "/safe-area/false" +const val SCREEN_TEXT_INPUT_ENDPOINT = "/text-input" const val CUSTOM_WIDGET_ENDPOINT = "/custom" diff --git a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/StyleConstants.kt b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/StyleConstants.kt index 761cee5aab..02f83bd62b 100644 --- a/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/StyleConstants.kt +++ b/backend/sample/core/src/main/kotlin/br/com/zup/beagle/sample/constants/StyleConstants.kt @@ -26,4 +26,4 @@ const val NAVIGATION_BAR_STYLE = "DesignSystem.Navigationbar.Style.Green" const val BUTTON_STYLE_TITLE = "DesignSystem.Button.Style" const val BUTTON_STYLE_ACCESSIBILITY = "DesignSystem.Button.White" const val NAVIGATION_BAR_STYLE_DEFAULT = "DesignSystem.Navigationbar.Style.Default" -const val TEXT_NETWORK_IMAGE = "DesignSystem.Text.NetworkImage" \ No newline at end of file +const val TEXT_IMAGE_REMOTE = "DesignSystem.Text.Image.Remote" \ No newline at end of file diff --git a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/controller/ScreenController.kt b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/controller/ScreenController.kt index 32551e87ae..86c7138ee8 100644 --- a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/controller/ScreenController.kt +++ b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/controller/ScreenController.kt @@ -36,6 +36,7 @@ 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_COMPONENTS_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_EXAMPLE_ENDPOINT import br.com.zup.beagle.sample.constants.SCREEN_FORM_ENDPOINT import br.com.zup.beagle.sample.constants.SCREEN_IMAGE_ENDPOINT @@ -44,9 +45,13 @@ 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_SAFE_AREA_FALSE_ENDPOINT +import br.com.zup.beagle.sample.constants.SCREEN_SAFE_AREA_TRUE_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.sample.micronaut.service.AccessibilityService @@ -56,14 +61,16 @@ import br.com.zup.beagle.sample.micronaut.service.SampleAnalyticsService import br.com.zup.beagle.sample.micronaut.service.SampleButtonService import br.com.zup.beagle.sample.micronaut.service.SampleComponentsService import br.com.zup.beagle.sample.micronaut.service.SampleComposeComponentService +import br.com.zup.beagle.sample.micronaut.service.SampleContextService import br.com.zup.beagle.sample.micronaut.service.SampleFormService -import br.com.zup.beagle.sample.micronaut.service.SampleImageService +import br.com.zup.beagle.sample.micronaut.service.SampleImageLocalService +import br.com.zup.beagle.sample.micronaut.service.SampleImageRemoteService import br.com.zup.beagle.sample.micronaut.service.SampleLazyComponentService import br.com.zup.beagle.sample.micronaut.service.SampleListViewService import br.com.zup.beagle.sample.micronaut.service.SampleNavigationBarService import br.com.zup.beagle.sample.micronaut.service.SampleNavigationTypeService -import br.com.zup.beagle.sample.micronaut.service.SampleNetworkImageService import br.com.zup.beagle.sample.micronaut.service.SamplePageViewService +import br.com.zup.beagle.sample.micronaut.service.SampleSafeAreaService import br.com.zup.beagle.sample.micronaut.service.SampleScreenBuilderService import br.com.zup.beagle.sample.micronaut.service.SampleScrollViewService import br.com.zup.beagle.sample.micronaut.service.SampleTabViewService @@ -71,8 +78,9 @@ import br.com.zup.beagle.sample.micronaut.service.SampleTextService import br.com.zup.beagle.sample.micronaut.service.SampleTouchableService import br.com.zup.beagle.sample.micronaut.service.SampleViewService import br.com.zup.beagle.sample.micronaut.service.SampleWebViewService -import io.micronaut.http.annotation.Controller +import br.com.zup.beagle.sample.micronaut.service.TextInputService import io.micronaut.http.annotation.Get +import io.micronaut.http.annotation.Controller @Controller class ScreenController( @@ -82,7 +90,7 @@ class ScreenController( private val sampleComponentsService: SampleComponentsService, private val sampleButtonService: SampleButtonService, private val sampleTextService: SampleTextService, - private val sampleImageService: SampleImageService, + private val sampleImageService: SampleImageLocalService, private val sampleTabViewService: SampleTabViewService, private val sampleListViewService: SampleListViewService, private val sampleScrollViewService: SampleScrollViewService, @@ -93,11 +101,14 @@ class ScreenController( private val sampleNavigationBarService: SampleNavigationBarService, private val sampleNavigationTypeService: SampleNavigationTypeService, private val sampleComposeComponentService: SampleComposeComponentService, - private val sampleNetworkImageService: SampleNetworkImageService, + private val sampleNetworkImageService: SampleImageRemoteService, private val sampleTouchableService: SampleTouchableService, private val sampleActionClickService: SampleActionClickService, private val sampleAnalyticsService: SampleAnalyticsService, - private val sampleWebViewService: SampleWebViewService + private val sampleWebViewService: SampleWebViewService, + private val sampleScreenContext: SampleContextService, + private val sampleScreenSafeArea: SampleSafeAreaService, + private val sampleScreenTextInput: TextInputService ) { @Get(ACCESSIBILITY_SCREEN_ENDPOINT) fun getAccessibilityView() = this.accessibilityService.createAccessibilityView() @@ -118,7 +129,7 @@ class ScreenController( fun getSampleTextView() = this.sampleTextService.createTextView() @Get(SCREEN_IMAGE_ENDPOINT) - fun getSampleImageView() = this.sampleImageService.createImageView() + fun getSampleImageView() = this.sampleImageService.createImageLocal() @Get(SCREEN_TAB_VIEW_ENDPOINT) fun getSampleTabViewView() = this.sampleTabViewService.createTabView() @@ -172,7 +183,7 @@ class ScreenController( fun getComposeComponent() = this.sampleComposeComponentService.createComposeComponentView() @Get(SCREEN_NETWORK_IMAGE_ENDPOINT) - fun getSampleNetworkImageView() = this.sampleNetworkImageService.createNetworkImage() + fun getSampleNetworkImageView() = this.sampleNetworkImageService.createImageRemote() @Get(SCREEN_BFF_NETWORK_IMAGE_ENDPOINT) fun getSampleBffNetworkImageView() = this.sampleNetworkImageService.createBffNetworkImage() @@ -191,4 +202,19 @@ class ScreenController( @Get(SCREEN_WEB_VIEW_ENDPOINT) fun getSampleWebViewService() = this.sampleWebViewService.createWebView() + + @Get(SCREEN_CONTEXT_ENDPOINT) + fun getSampleContext() = this.sampleScreenContext.createScreenContext() + + @Get(SCREEN_SAFE_AREA_ENDPOINT) + fun getSampleSafeArea() = this.sampleScreenSafeArea.createSafeArea() + + @Get(SCREEN_SAFE_AREA_TRUE_ENDPOINT) + fun getSampleSafeAreaTrue() = this.sampleScreenSafeArea.createSafeAreaTrue() + + @Get(SCREEN_SAFE_AREA_FALSE_ENDPOINT) + fun getSampleSafeAreaFalse() = this.sampleScreenSafeArea.createSafeAreaFalse() + + @Get(SCREEN_TEXT_INPUT_ENDPOINT) + fun getSampleTextInput() = this.sampleScreenTextInput.createScreenTextInput() } diff --git a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleContextService.kt b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleContextService.kt new file mode 100644 index 0000000000..fc6bcb8bbd --- /dev/null +++ b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleContextService.kt @@ -0,0 +1,24 @@ +/* + * 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.micronaut.service +import br.com.zup.beagle.sample.builder.ScreenContextBuilder +import javax.inject.Singleton + +@Singleton +class SampleContextService { + fun createScreenContext() = ScreenContextBuilder +} diff --git a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageLocalService.kt b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageLocalService.kt new file mode 100644 index 0000000000..7532238ae2 --- /dev/null +++ b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageLocalService.kt @@ -0,0 +1,25 @@ +/* + * 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.micronaut.service + +import br.com.zup.beagle.sample.builder.ImageLocalScreenBuilder +import javax.inject.Singleton + +@Singleton +class SampleImageLocalService { + fun createImageLocal() = ImageLocalScreenBuilder +} diff --git a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleNetworkImageService.kt b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageRemoteService.kt similarity index 76% rename from backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleNetworkImageService.kt rename to backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageRemoteService.kt index 4668dfe119..aaa1952300 100644 --- a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleNetworkImageService.kt +++ b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageRemoteService.kt @@ -16,14 +16,14 @@ package br.com.zup.beagle.sample.micronaut.service -import br.com.zup.beagle.sample.builder.NetworkImageScreenBuilder +import br.com.zup.beagle.sample.builder.ImageRemoteScreenBuilder import br.com.zup.beagle.sample.constants.BEACH_NETWORK_IMAGE import br.com.zup.beagle.sample.constants.BFF_BEACH_NETWORK_IMAGE import javax.inject.Singleton @Singleton -class SampleNetworkImageService { - fun createNetworkImage() = NetworkImageScreenBuilder(BEACH_NETWORK_IMAGE) +class SampleImageRemoteService { + fun createImageRemote() = ImageRemoteScreenBuilder(BEACH_NETWORK_IMAGE) - fun createBffNetworkImage() = NetworkImageScreenBuilder(BFF_BEACH_NETWORK_IMAGE) + fun createBffNetworkImage() = ImageRemoteScreenBuilder(BFF_BEACH_NETWORK_IMAGE) } diff --git a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleSafeAreaService.kt b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleSafeAreaService.kt new file mode 100644 index 0000000000..f8c03403a7 --- /dev/null +++ b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleSafeAreaService.kt @@ -0,0 +1,29 @@ +/* + * 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.micronaut.service + +import br.com.zup.beagle.sample.builder.SafeAreaBuilder +import javax.inject.Singleton + +@Singleton +class SampleSafeAreaService { + fun createSafeArea() = SafeAreaBuilder + + fun createSafeAreaTrue() = SafeAreaBuilder.createScreen(true) + + fun createSafeAreaFalse() = SafeAreaBuilder.createScreen(false) +} diff --git a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageService.kt b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/TextInputService.kt similarity index 84% rename from backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageService.kt rename to backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/TextInputService.kt index a879b6e9be..0e1ffd8d21 100644 --- a/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/SampleImageService.kt +++ b/backend/sample/micronaut/src/main/kotlin/br/com/zup/beagle/sample/micronaut/service/TextInputService.kt @@ -16,10 +16,10 @@ package br.com.zup.beagle.sample.micronaut.service -import br.com.zup.beagle.sample.builder.ImageScreenBuilder +import br.com.zup.beagle.sample.builder.TextInputBuilder import javax.inject.Singleton @Singleton -class SampleImageService { - fun createImageView() = ImageScreenBuilder +class TextInputService { + fun createScreenTextInput() = TextInputBuilder } diff --git a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/controller/ScreenController.kt b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/controller/ScreenController.kt index 341d4e1a3a..bc4d9c6e8b 100644 --- a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/controller/ScreenController.kt +++ b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/controller/ScreenController.kt @@ -36,6 +36,7 @@ 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_COMPONENTS_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_EXAMPLE_ENDPOINT import br.com.zup.beagle.sample.constants.SCREEN_FORM_ENDPOINT import br.com.zup.beagle.sample.constants.SCREEN_IMAGE_ENDPOINT @@ -44,9 +45,13 @@ 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_SAFE_AREA_FALSE_ENDPOINT +import br.com.zup.beagle.sample.constants.SCREEN_SAFE_AREA_TRUE_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.sample.spring.service.AccessibilityService @@ -56,14 +61,16 @@ import br.com.zup.beagle.sample.spring.service.SampleAnalyticsService import br.com.zup.beagle.sample.spring.service.SampleButtonService import br.com.zup.beagle.sample.spring.service.SampleComponentsService import br.com.zup.beagle.sample.spring.service.SampleComposeComponentService +import br.com.zup.beagle.sample.spring.service.SampleContextService import br.com.zup.beagle.sample.spring.service.SampleFormService -import br.com.zup.beagle.sample.spring.service.SampleImageService +import br.com.zup.beagle.sample.spring.service.SampleImageLocalService +import br.com.zup.beagle.sample.spring.service.SampleImageRemoteService import br.com.zup.beagle.sample.spring.service.SampleLazyComponentService import br.com.zup.beagle.sample.spring.service.SampleListViewService import br.com.zup.beagle.sample.spring.service.SampleNavigationBarService import br.com.zup.beagle.sample.spring.service.SampleNavigationTypeService -import br.com.zup.beagle.sample.spring.service.SampleNetworkImageService import br.com.zup.beagle.sample.spring.service.SamplePageViewService +import br.com.zup.beagle.sample.spring.service.SampleSafeAreaService import br.com.zup.beagle.sample.spring.service.SampleScreenBuilderService import br.com.zup.beagle.sample.spring.service.SampleScrollViewService import br.com.zup.beagle.sample.spring.service.SampleTabViewService @@ -71,8 +78,9 @@ import br.com.zup.beagle.sample.spring.service.SampleTextService import br.com.zup.beagle.sample.spring.service.SampleTouchableService import br.com.zup.beagle.sample.spring.service.SampleViewService import br.com.zup.beagle.sample.spring.service.SampleWebViewService -import org.springframework.web.bind.annotation.RestController +import br.com.zup.beagle.sample.spring.service.TextInputService import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RestController @RestController class ScreenController( @@ -82,7 +90,7 @@ class ScreenController( private val sampleComponentsService: SampleComponentsService, private val sampleButtonService: SampleButtonService, private val sampleTextService: SampleTextService, - private val sampleImageService: SampleImageService, + private val sampleImageService: SampleImageLocalService, private val sampleTabViewService: SampleTabViewService, private val sampleListViewService: SampleListViewService, private val sampleScrollViewService: SampleScrollViewService, @@ -93,11 +101,14 @@ class ScreenController( private val sampleNavigationBarService: SampleNavigationBarService, private val sampleNavigationTypeService: SampleNavigationTypeService, private val sampleComposeComponentService: SampleComposeComponentService, - private val sampleNetworkImageService: SampleNetworkImageService, + private val sampleNetworkImageService: SampleImageRemoteService, private val sampleTouchableService: SampleTouchableService, private val sampleActionClickService: SampleActionClickService, private val sampleAnalyticsService: SampleAnalyticsService, - private val sampleWebViewService: SampleWebViewService + private val sampleWebViewService: SampleWebViewService, + private val sampleScreenContext: SampleContextService, + private val sampleScreenSafeArea: SampleSafeAreaService, + private val sampleScreenTextInput: TextInputService ) { @GetMapping(ACCESSIBILITY_SCREEN_ENDPOINT) fun getAccessibilityView() = this.accessibilityService.createAccessibilityView() @@ -118,7 +129,7 @@ class ScreenController( fun getSampleTextView() = this.sampleTextService.createTextView() @GetMapping(SCREEN_IMAGE_ENDPOINT) - fun getSampleImageView() = this.sampleImageService.createImageView() + fun getSampleImageView() = this.sampleImageService.createImageLocal() @GetMapping(SCREEN_TAB_VIEW_ENDPOINT) fun getSampleTabViewView() = this.sampleTabViewService.createTabView() @@ -172,7 +183,7 @@ class ScreenController( fun getComposeComponent() = this.sampleComposeComponentService.createComposeComponentView() @GetMapping(SCREEN_NETWORK_IMAGE_ENDPOINT) - fun getSampleNetworkImageView() = this.sampleNetworkImageService.createNetworkImage() + fun getSampleNetworkImageView() = this.sampleNetworkImageService.createImageRemote() @GetMapping(SCREEN_BFF_NETWORK_IMAGE_ENDPOINT) fun getSampleBffNetworkImageView() = this.sampleNetworkImageService.createBffNetworkImage() @@ -191,4 +202,19 @@ class ScreenController( @GetMapping(SCREEN_WEB_VIEW_ENDPOINT) fun getSampleWebViewService() = this.sampleWebViewService.createWebView() + + @GetMapping(SCREEN_CONTEXT_ENDPOINT) + fun getSampleContext() = this.sampleScreenContext.createScreenContext() + + @GetMapping(SCREEN_SAFE_AREA_ENDPOINT) + fun getSampleSafeArea() = this.sampleScreenSafeArea.createSafeArea() + + @GetMapping(SCREEN_SAFE_AREA_TRUE_ENDPOINT) + fun getSampleSafeAreaTrue() = this.sampleScreenSafeArea.createSafeAreaTrue() + + @GetMapping(SCREEN_SAFE_AREA_FALSE_ENDPOINT) + fun getSampleSafeAreaFalse() = this.sampleScreenSafeArea.createSafeAreaFalse() + + @GetMapping(SCREEN_TEXT_INPUT_ENDPOINT) + fun getSampleTextInput() = this.sampleScreenTextInput.createScreenTextInput() } diff --git a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleContextService.kt b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleContextService.kt new file mode 100644 index 0000000000..c21c346817 --- /dev/null +++ b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleContextService.kt @@ -0,0 +1,24 @@ +/* + * 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.spring.service +import br.com.zup.beagle.sample.builder.ScreenContextBuilder +import org.springframework.stereotype.Service + +@Service +class SampleContextService { + fun createScreenContext() = ScreenContextBuilder +} \ No newline at end of file diff --git a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageLocalService.kt b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageLocalService.kt new file mode 100644 index 0000000000..5a4d0f8f10 --- /dev/null +++ b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageLocalService.kt @@ -0,0 +1,25 @@ +/* + * 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.spring.service + +import br.com.zup.beagle.sample.builder.ImageLocalScreenBuilder +import org.springframework.stereotype.Service + +@Service +class SampleImageLocalService { + fun createImageLocal() = ImageLocalScreenBuilder +} diff --git a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleNetworkImageService.kt b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageRemoteService.kt similarity index 76% rename from backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleNetworkImageService.kt rename to backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageRemoteService.kt index 51ca02008c..c949fb6820 100644 --- a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleNetworkImageService.kt +++ b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageRemoteService.kt @@ -16,14 +16,14 @@ package br.com.zup.beagle.sample.spring.service -import br.com.zup.beagle.sample.builder.NetworkImageScreenBuilder +import br.com.zup.beagle.sample.builder.ImageRemoteScreenBuilder import br.com.zup.beagle.sample.constants.BEACH_NETWORK_IMAGE import br.com.zup.beagle.sample.constants.BFF_BEACH_NETWORK_IMAGE import org.springframework.stereotype.Service @Service -class SampleNetworkImageService { - fun createNetworkImage() = NetworkImageScreenBuilder(BEACH_NETWORK_IMAGE) +class SampleImageRemoteService { + fun createImageRemote() = ImageRemoteScreenBuilder(BEACH_NETWORK_IMAGE) - fun createBffNetworkImage() = NetworkImageScreenBuilder(BFF_BEACH_NETWORK_IMAGE) + fun createBffNetworkImage() = ImageRemoteScreenBuilder(BFF_BEACH_NETWORK_IMAGE) } diff --git a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleSafeAreaService.kt b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleSafeAreaService.kt new file mode 100644 index 0000000000..49991df2ae --- /dev/null +++ b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleSafeAreaService.kt @@ -0,0 +1,29 @@ +/* + * 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.spring.service + +import br.com.zup.beagle.sample.builder.SafeAreaBuilder +import org.springframework.stereotype.Service + +@Service +class SampleSafeAreaService { + fun createSafeArea() = SafeAreaBuilder + + fun createSafeAreaTrue() = SafeAreaBuilder.createScreen(true) + + fun createSafeAreaFalse() = SafeAreaBuilder.createScreen(false) +} \ No newline at end of file diff --git a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageService.kt b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/TextInputService.kt similarity index 84% rename from backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageService.kt rename to backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/TextInputService.kt index 0db7a66426..4b6be743ca 100644 --- a/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/SampleImageService.kt +++ b/backend/sample/spring/src/main/kotlin/br/com/zup/beagle/sample/spring/service/TextInputService.kt @@ -16,10 +16,10 @@ package br.com.zup.beagle.sample.spring.service -import br.com.zup.beagle.sample.builder.ImageScreenBuilder +import br.com.zup.beagle.sample.builder.TextInputBuilder import org.springframework.stereotype.Service @Service -class SampleImageService { - fun createImageView() = ImageScreenBuilder -} +class TextInputService { + fun createScreenTextInput() = TextInputBuilder +} \ No newline at end of file diff --git a/iOS/Example/BeagleDemo/BeagleDemo/BeagleStyle.swift b/iOS/Example/BeagleDemo/BeagleDemo/BeagleStyle.swift index bfdb27f7f1..96d6004a7e 100644 --- a/iOS/Example/BeagleDemo/BeagleDemo/BeagleStyle.swift +++ b/iOS/Example/BeagleDemo/BeagleDemo/BeagleStyle.swift @@ -31,7 +31,9 @@ struct AppTheme { .NAVIGATION_BAR_GREEN_STYLE: Self.designSystemStyleNavigationBar, .NAVIGATION_BAR_DEFAULT_STYLE: Self.designSystemStyleNavigationBarDefault, .TAB_VIEW_STYLE: Self.tabView, - .TEXT_INPUT_STYLE: Self.designSystemTextInput + .TEXT_INPUT_STYLE: Self.designSystemTextInput, + .TEXT_INPUT_STYLE_BFF: textInput, + .BUTTON_STYLE_CONTEXT_BFF: designSystemButtonScreenContext ]) static func blackTextNormalStyle() -> (UITextView?) -> Void { @@ -97,4 +99,17 @@ struct AppTheme { static func tabView() -> (UIView?) -> Void { return BeagleStyle.tabView(backgroundColor: .clear, indicatorColor: .demoGray, selectedTextColor: .demoGray, unselectedTextColor: .demoDarkGray, selectedIconColor: .demoGray, unselectedIconColor: .demoDarkGray) } + + static func textInput() -> (UITextField?) -> Void { + return { + $0?.borderStyle = UITextField.BorderStyle.roundedRect + } + } + + static func designSystemButtonScreenContext() -> (UIButton?) -> Void { + return BeagleStyle.button(withTitleColor: .white) + <> { + $0?.titleLabel |> BeagleStyle.label(withFont: .systemFont(ofSize: 16, weight: .semibold)) + } + } } diff --git a/iOS/Example/BeagleDemo/BeagleDemo/Constants/Constants.swift b/iOS/Example/BeagleDemo/BeagleDemo/Constants/Constants.swift index 9e8915c732..c3ac8a56be 100644 --- a/iOS/Example/BeagleDemo/BeagleDemo/Constants/Constants.swift +++ b/iOS/Example/BeagleDemo/BeagleDemo/Constants/Constants.swift @@ -53,6 +53,8 @@ extension String { static let TEXT_IMAGE_STYLE = "DesignSystem.Text.Image" static let TEXT_HELLO_WORD_STYLE = "DesignSystem.Text.helloWord" static let TEXT_INPUT_STYLE = "DesignSystem.TextInput.Style" + static let TEXT_INPUT_STYLE_BFF = "DesignSystem.TextInput.Style.Bff" + static let BUTTON_STYLE_CONTEXT_BFF = "DesignSystem.Button.Context" } extension UIColor {