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

Commit

Permalink
feat: image expression (#914)
Browse files Browse the repository at this point in the history
* adding image expression

* Changing the image component and adding tests

* small modification

* change navigation type screen

* implement context tab bar + navigationbar

* adding image test

* adding test to navigationBar item with context

* change demo + remove deprecated

* renaming typealias + fixes

* fixing comment

* updating snapshot test

* just reducing snapshot image size

* code indentation

* image configure binding fix

* fix markDirty

* refactoring tab bar

* adding image black hole

* fixing some bugs + tests

* fix indicator

* fixing size

* organize methods

* fixing item size and tests

* undoing expression test change

* undoing expression test change

* removing unecessary condition

* removing unecessary function

* different approach instead of using addBindin

* apply style improvements

* removing unecessary code

* adding scrollView to the image screen

* change in animation of the component

* change in animation of the component

* remove swiftlint:disable

* fix image-tests

* change tabbar scroll

Co-authored-by: theffc <[email protected]>
Co-authored-by: Gabriela Coelho <[email protected]>
Co-authored-by: Daniel Tes Carrasque <[email protected]>
Co-authored-by: Lucas Araújo <[email protected]>
  • Loading branch information
5 people authored Oct 13, 2020
1 parent 19b3500 commit 56874de
Show file tree
Hide file tree
Showing 56 changed files with 966 additions and 649 deletions.
12 changes: 8 additions & 4 deletions iOS/Example/BeagleDemo/BeagleDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
6E4EE6C1240E970000624DFB /* ScreenDeepLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E4EE6C0240E970000624DFB /* ScreenDeepLink.swift */; };
6E4EE6C7240E9C0B00624DFB /* ViewLayoutHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E4EE6C6240E9C0B00624DFB /* ViewLayoutHelper.swift */; };
6E8E1CC1249C57300053AD58 /* SimpleForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E8E1CC0249C57300053AD58 /* SimpleForm.swift */; };
6EA428722514457F00AEE741 /* ImageScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EA428712514457F00AEE741 /* ImageScreen.swift */; };
6ED5B09E240464520070CB9D /* BeagleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6ED5B09D240464520070CB9D /* BeagleStyle.swift */; };
7685B043249A879F007EDED0 /* SendRequestScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7685B042249A879F007EDED0 /* SendRequestScreen.swift */; };
932925B22327E0E400A61F01 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932925B12327E0E400A61F01 /* AppDelegate.swift */; };
Expand All @@ -27,7 +28,7 @@
93D24A742514F9DA005A5CBD /* BeagleViewScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D24A732514F9DA005A5CBD /* BeagleViewScreen.swift */; };
93D8DC0D248965D10070CB41 /* ComponentInteractionScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D8DC0C248965D10070CB41 /* ComponentInteractionScreen.swift */; };
93EAFA4C24083C7B00B73522 /* ListViewScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EAFA4B24083C7B00B73522 /* ListViewScreen.swift */; };
98A7F36C23A926C600E88C70 /* TabViewScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A7F36B23A926C600E88C70 /* TabViewScreen.swift */; };
98A7F36C23A926C600E88C70 /* TabBarScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98A7F36B23A926C600E88C70 /* TabBarScreen.swift */; };
98E08D2324228DD200FBD21B /* WebViewScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98E08D2224228DD200FBD21B /* WebViewScreen.swift */; };
98F3D41124ED770F006DAB05 /* NavigateTypeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F3D41024ED770F006DAB05 /* NavigateTypeScreen.swift */; };
A038C8FD2407073D001164B1 /* FormScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = A038C8FC2407073D001164B1 /* FormScreen.swift */; };
Expand Down Expand Up @@ -104,6 +105,7 @@
6E4EE6C0240E970000624DFB /* ScreenDeepLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenDeepLink.swift; sourceTree = "<group>"; };
6E4EE6C6240E9C0B00624DFB /* ViewLayoutHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewLayoutHelper.swift; sourceTree = "<group>"; };
6E8E1CC0249C57300053AD58 /* SimpleForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleForm.swift; sourceTree = "<group>"; };
6EA428712514457F00AEE741 /* ImageScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageScreen.swift; sourceTree = "<group>"; };
6ED5B09D240464520070CB9D /* BeagleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeagleStyle.swift; sourceTree = "<group>"; };
7685B042249A879F007EDED0 /* SendRequestScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SendRequestScreen.swift; sourceTree = "<group>"; };
932925AE2327E0E400A61F01 /* BeagleDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BeagleDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -117,7 +119,7 @@
93D24A732514F9DA005A5CBD /* BeagleViewScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeagleViewScreen.swift; sourceTree = "<group>"; };
93D8DC0C248965D10070CB41 /* ComponentInteractionScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentInteractionScreen.swift; sourceTree = "<group>"; };
93EAFA4B24083C7B00B73522 /* ListViewScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListViewScreen.swift; sourceTree = "<group>"; };
98A7F36B23A926C600E88C70 /* TabViewScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewScreen.swift; sourceTree = "<group>"; };
98A7F36B23A926C600E88C70 /* TabBarScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarScreen.swift; sourceTree = "<group>"; };
98E08D2224228DD200FBD21B /* WebViewScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewScreen.swift; sourceTree = "<group>"; };
98F3D41024ED770F006DAB05 /* NavigateTypeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigateTypeScreen.swift; sourceTree = "<group>"; };
A038C8FC2407073D001164B1 /* FormScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormScreen.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -262,9 +264,10 @@
6E4EE6C0240E970000624DFB /* ScreenDeepLink.swift */,
7685B042249A879F007EDED0 /* SendRequestScreen.swift */,
6E8E1CC0249C57300053AD58 /* SimpleForm.swift */,
98A7F36B23A926C600E88C70 /* TabViewScreen.swift */,
98A7F36B23A926C600E88C70 /* TabBarScreen.swift */,
6E4EE6C6240E9C0B00624DFB /* ViewLayoutHelper.swift */,
98E08D2224228DD200FBD21B /* WebViewScreen.swift */,
6EA428712514457F00AEE741 /* ImageScreen.swift */,
4F36AB2D251E7A5A0036F839 /* GlobalContextScreen.swift */,
);
path = Screens;
Expand Down Expand Up @@ -524,11 +527,12 @@
A0642DCB23968A020028AFF3 /* MainScreen.swift in Sources */,
C80AF1342493F0950097D200 /* OtherComponent.swift in Sources */,
C09F4100249AAB0F002605EE /* TextContainerWithAction.swift in Sources */,
6EA428722514457F00AEE741 /* ImageScreen.swift in Sources */,
2576F469250ACF6C000CDB2A /* NativeViewController.swift in Sources */,
C8A2F6F42464C1F9002198B1 /* AutoDecodable.generated.swift in Sources */,
93EAFA4C24083C7B00B73522 /* ListViewScreen.swift in Sources */,
932925B22327E0E400A61F01 /* AppDelegate.swift in Sources */,
98A7F36C23A926C600E88C70 /* TabViewScreen.swift in Sources */,
98A7F36C23A926C600E88C70 /* TabBarScreen.swift in Sources */,
A057D59824C9FE1D001F6835 /* ErrorView.swift in Sources */,
98E08D2324228DD200FBD21B /* WebViewScreen.swift in Sources */,
A0642DC82395A1840028AFF3 /* DeeplinkScreenManager.swift in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion iOS/Example/BeagleDemo/BeagleDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let deepLinkHandler = DeeplinkScreenManager.shared
deepLinkHandler[.lazyComponentEndpoint] = LazyComponentScreen.self
deepLinkHandler[.pageViewEndpoint] = PageViewScreen.self
deepLinkHandler[.tabViewEndpoint] = TabViewScreen.self
deepLinkHandler[.tabBarEndpoint] = TabBarScreen.self
deepLinkHandler[.formEndpoint] = FormScreen.self
deepLinkHandler[.customComponentEndpoint] = CustomComponentScreen.self
deepLinkHandler[.screenDeeplinkEndpoint] = ScreenDeepLink.self
Expand All @@ -38,6 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
deepLinkHandler[.simpleFormEndpoint] = SimpleFormScreen.self
deepLinkHandler[.navigateStep1Endpoint] = NavigateStep1Screen.self
deepLinkHandler[.navigateStep2Endpoint] = NavigateStep2Screen.self
deepLinkHandler[.imageEndpoint] = ImageScreen.self
deepLinkHandler[.globalContextEndpoint] = GlobalContexScreen.self
deepLinkHandler[.beagleView] = BeagleViewScreen.self

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "beagle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "buracoNegro.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion iOS/Example/BeagleDemo/BeagleDemo/BeagleStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct AppTheme {
}

static func tabView() -> (UIView?) -> Void {
return BeagleStyle.tabBar(backgroundColor: .clear, indicatorColor: .demoGray, selectedTextColor: .demoGray, unselectedTextColor: .demoDarkGray, selectedIconColor: .demoGray, unselectedIconColor: .demoDarkGray)
return BeagleStyle.tabBar(backgroundColor: .clear, indicatorColor: .demoGray, selectedTextColor: .demoGray, unselectedTextColor: .demoDarkGray)
}

static func textInput() -> (UITextField?) -> Void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 1.0.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 0.18.0 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 1.0.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 0.18.0 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

/*
Expand Down
3 changes: 2 additions & 1 deletion iOS/Example/BeagleDemo/BeagleDemo/Constants/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension String {
// MARK: - Endpoint
static let lazyComponentEndpoint = "lazycomponent"
static let pageViewEndpoint = "pageview"
static let tabViewEndpoint = "tabview"
static let tabBarEndpoint = "tabbar"
static let listViewEndpoint = "listview"
static let formEndpoint = "form"
static let customComponentEndpoint = "customComponent"
Expand All @@ -42,6 +42,7 @@ extension String {
static let componentInterationEndpoint = "componentInteractionText"
static let conditionActionEndpoint = "conditionActionText"
static let simpleFormEndpoint = "simpleFormComponent"
static let imageEndpoint = "image"

// MARK: - URL
static let webViewURL = "https://maps.google.com/"
Expand Down
118 changes: 118 additions & 0 deletions iOS/Example/BeagleDemo/BeagleDemo/Screens/ImageScreen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* 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.
*/

import UIKit
import Beagle
import BeagleSchema

struct ImageScreen: DeeplinkScreen {

init(path: String, data: [String: String]?) {
// Intentionally unimplemented...
}

func screenController() -> UIViewController {
return Beagle.screen(.declarative(screen))
}

var screen: Screen {
return Screen(
navigationBar: NavigationBar(title: "Image"),
child: container()
)
}

private let sizeImage = WidgetProperties(
style: Style(
size: Size().height(100).width(100),
flex: Flex().alignSelf(.center)
)
)

private func container() -> Container {
return Container(context: Context(
id: "img",
value: [
"remote": .string(.networkImageBeagle),
"local": "imageBeagle",
"pathLocal": ["_beagleImagePath_": "local", "mobileId": "imageBeagle"],
"pathRemote": ["_beagleImagePath_": "remote", "url": .string(.networkImageBeagle)]
]
)) {
ScrollView {
createText(text: "Image url with context!")
Image(
.remote(Image.Remote(url: "@{img.remote}")),
widgetProperties: sizeImage
)

createText(text: "Image mobileId with context!")
Image(
.local("@{img.local}"),
widgetProperties: sizeImage
)
createText(text: "Image with type remote path with context!")
Image(
"@{img.pathRemote}",
widgetProperties: sizeImage
)
createText(text: "Image with type local path with context!")
Image(
"@{img.pathLocal}",
widgetProperties: sizeImage
)
createText(text: "Image url without context!")
Image(
.remote(.init(url: .networkImageBeagle)),
widgetProperties: sizeImage
)

createText(text: "Image mobileId without context!")
Image(
.local("beagle"),
widgetProperties: sizeImage
)

Button(
text: "Chage Context",
onPress: [
SetContext(
contextId: "img",
value: [
"remote": "https://cdn.eso.org/images/screen/eso1907a.jpg",
"local": "beagle",
"pathLocal": ["_beagleImagePath_": "local", "mobileId": "beagle"],
"pathRemote": ["_beagleImagePath_": "remote", "url": "https://cdn.eso.org/images/screen/eso1907a.jpg"]
]
)
]
)
}
}
}

private func createText(text: String) -> Text {
return Text(
.value(text),
widgetProperties: WidgetProperties(
style: Style(
margin: EdgeValue().vertical(10),
flex: Flex().alignSelf(.center)
)
)
)
}
}
22 changes: 16 additions & 6 deletions iOS/Example/BeagleDemo/BeagleDemo/Screens/ListViewScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,24 @@ struct ListViewScreen: DeeplinkScreen {

var screen: Screen {
return Screen(
navigationBar: NavigationBar(title: "ListView"),
child: listView
navigationBar: NavigationBar(
title: "ListView",
navigationBarItems: [
NavigationBarItem(
image: "@{img}",
text: "",
action: SetContext(contextId: "img", value: "imageBeagle")
)
]
),
child: listView,
context: Context(id: "img", value: "informationImage")
)
}

var listView = ListView(direction: .horizontal) {
Touchable(onPress: [Navigate.pushView(.remote(.init(url: .value(.textLazyComponentEndpoint))))]) {
Text("0000")
Touchable(onPress: [Navigate.pushView(.remote(.init(url: .textLazyComponentEndpoint)))]) {
Text("0000")
}
Text("0001", widgetProperties: .init(style: Style(size: Size().width(100).height(100))))
Text("0002")
Expand All @@ -55,11 +65,11 @@ struct ListViewScreen: DeeplinkScreen {
Text("0011")
Text("0012")
Text("0013")
Image(.value(.local("beagle")))
Image(.local("beagle"))
Text("0014")
Text("0015")
Text("0016")
Image(.value(.remote(.init(url: .networkImageBeagle))))
Image(.remote(.init(url: .networkImageBeagle)))
Text("0017")
Text("0018")
Text("0019")
Expand Down
11 changes: 8 additions & 3 deletions iOS/Example/BeagleDemo/BeagleDemo/Screens/MainScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ struct MainScreen: DeeplinkScreen {
onPress: [Navigate.openNativeRoute(.init(route: .pageViewEndpoint))]
)
Button(
text: "Tab View",
onPress: [Navigate.openNativeRoute(.init(route: .tabViewEndpoint))]
text: "Tab Bar",
onPress: [Navigate.openNativeRoute(.init(route: .tabBarEndpoint))]
)
Button(
text: "List View",
onPress: [Navigate.openNativeRoute(.init(route: .listViewEndpoint))]
)
Button(
text: "Image",
onPress: [Navigate.openNativeRoute(.init(route: .imageEndpoint))]
)
Button(
text: "Form",
onPress: [Navigate.openNativeRoute(.init(route: .formEndpoint))]
Expand Down Expand Up @@ -104,7 +108,7 @@ struct MainScreen: DeeplinkScreen {
)
Button(
text: "Sample BFF",
onPress: [Navigate.pushView(.remote(.init(url: .value(.componentsEndpoint))))]
onPress: [Navigate.pushView(.remote(.init(url: .componentsEndpoint)))]
)
}
}
Expand All @@ -114,4 +118,5 @@ struct MainScreen: DeeplinkScreen {
title: "Beagle Demo"
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct Page {
Text("Text with alignment attribute set to center", alignment: Expression.value(.center))
Text("Text with alignment attribute set to right", alignment: Expression.value(.right))
Text("Text with alignment attribute set to left", alignment: Expression.value(.left))
Image(.value(.remote(.init(url: .networkImageBeagle))))
Image(.remote(.init(url: .networkImageBeagle)))
}
}
}
Loading

0 comments on commit 56874de

Please sign in to comment.