Skip to content

Commit 04e7d25

Browse files
New Sample: Switch (#281)
* New Sample: Switch (1) * New Sample: Switch (2) * New Sample: Switch (3)
1 parent d10b209 commit 04e7d25

File tree

3 files changed

+168
-0
lines changed

3 files changed

+168
-0
lines changed

src/z2ui5_cl_demo_app_000.clas.abap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
468468
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
469469
).
470470

471+
panel->generic_tile(
472+
header = 'Switch'
473+
press = client->_event( 'Z2UI5_CL_DEMO_APP_240' )
474+
mode = 'LineMode'
475+
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
476+
).
477+
471478
panel = page->panel(
472479
expandable = abap_false
473480
expanded = abap_true
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
class z2ui5_cl_demo_app_240 definition
2+
public
3+
create public .
4+
5+
public section.
6+
7+
interfaces IF_SERIALIZABLE_OBJECT .
8+
interfaces Z2UI5_IF_APP .
9+
10+
data CHECK_INITIALIZED type ABAP_BOOL .
11+
PROTECTED SECTION.
12+
13+
DATA client TYPE REF TO z2ui5_if_client.
14+
15+
METHODS display_view
16+
IMPORTING
17+
client TYPE REF TO z2ui5_if_client.
18+
METHODS on_event
19+
IMPORTING
20+
client TYPE REF TO z2ui5_if_client.
21+
METHODS z2ui5_display_popover
22+
IMPORTING
23+
id TYPE string.
24+
25+
PRIVATE SECTION.
26+
ENDCLASS.
27+
28+
29+
30+
CLASS z2ui5_cl_demo_app_240 IMPLEMENTATION.
31+
32+
33+
METHOD DISPLAY_VIEW.
34+
35+
DATA(page) = z2ui5_cl_xml_view=>factory( )->shell(
36+
)->page(
37+
title = `abap2UI5 - Sample: Switch`
38+
navbuttonpress = client->_event( 'BACK' )
39+
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) ).
40+
41+
page->header_content(
42+
)->button( id = `hint_icon`
43+
icon = `sap-icon://hint`
44+
tooltip = `Sample information`
45+
press = client->_event( 'POPOVER' ) ).
46+
47+
page->header_content(
48+
)->link(
49+
text = 'UI5 Demo Kit'
50+
target = '_blank'
51+
href = 'https://sapui5.hana.ondemand.com/sdk/#/entity/sap.m.Switch/sample/sap.m.sample.Switch' ).
52+
53+
DATA(layout) = page->vbox(
54+
class = `sapUiSmallMargin`
55+
)->hbox(
56+
)->switch( state = abap_true )->get(
57+
)->layout_data(
58+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
59+
)->switch( state = abap_false )->get(
60+
)->layout_data(
61+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
62+
)->switch( state = abap_true enabled = abap_false )->get(
63+
)->layout_data(
64+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent( )->get_parent(
65+
66+
)->hbox(
67+
)->switch( state = abap_true customtexton = `Yes` customtextoff = `No` )->get(
68+
)->layout_data(
69+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
70+
)->switch( state = abap_false customtexton = `Yes` customtextoff = `No` )->get(
71+
)->layout_data(
72+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
73+
)->switch( state = abap_true customtexton = `Yes` customtextoff = `No` enabled = abap_false )->get(
74+
)->layout_data(
75+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent( )->get_parent(
76+
77+
)->hbox(
78+
)->switch( state = abap_true customtexton = ` ` customtextoff = ` ` )->get(
79+
)->layout_data(
80+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
81+
)->switch( state = abap_false customtexton = ` ` customtextoff = ` ` )->get(
82+
)->layout_data(
83+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
84+
)->switch( state = abap_true customtexton = ` ` customtextoff = ` ` enabled = abap_false )->get(
85+
)->layout_data(
86+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent( )->get_parent(
87+
88+
)->hbox(
89+
)->switch( type = `AcceptReject` state = abap_true )->get(
90+
)->layout_data(
91+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
92+
)->switch( type = `AcceptReject` )->get(
93+
)->layout_data(
94+
)->flex_item_data( growfactor = `1` )->get_parent( )->get_parent(
95+
)->switch( type = `AcceptReject` state = abap_true enabled = abap_false )->get(
96+
)->layout_data(
97+
)->flex_item_data( growfactor = `1`
98+
).
99+
100+
client->view_display( page->stringify( ) ).
101+
102+
ENDMETHOD.
103+
104+
105+
METHOD ON_EVENT.
106+
107+
CASE client->get( )-event.
108+
WHEN 'BACK'.
109+
client->nav_app_leave( ).
110+
WHEN 'POPOVER'.
111+
z2ui5_display_popover( `hint_icon` ).
112+
ENDCASE.
113+
114+
ENDMETHOD.
115+
116+
117+
METHOD Z2UI5_DISPLAY_POPOVER.
118+
119+
DATA(view) = z2ui5_cl_xml_view=>factory_popup( ).
120+
view->quick_view( placement = `Bottom` width = `auto`
121+
)->quick_view_page( pageid = `sampleInformationId`
122+
header = `Sample information`
123+
description = `"Some say it is only a switch, I say it is one of the most stylish controls in the universe of mobile UI controls." (unknown developer)` ).
124+
125+
client->popover_display(
126+
xml = view->stringify( )
127+
by_id = id
128+
).
129+
130+
ENDMETHOD.
131+
132+
133+
METHOD Z2UI5_IF_APP~MAIN.
134+
135+
me->client = client.
136+
137+
IF check_initialized = abap_false.
138+
check_initialized = abap_true.
139+
display_view( client ).
140+
ENDIF.
141+
142+
on_event( client ).
143+
144+
ENDMETHOD.
145+
ENDCLASS.

src/z2ui5_cl_demo_app_240.clas.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<VSEOCLASS>
6+
<CLSNAME>Z2UI5_CL_DEMO_APP_240</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>Switch</DESCRIPT>
9+
<STATE>1</STATE>
10+
<CLSCCINCL>X</CLSCCINCL>
11+
<FIXPT>X</FIXPT>
12+
<UNICODE>X</UNICODE>
13+
</VSEOCLASS>
14+
</asx:values>
15+
</asx:abap>
16+
</abapGit>

0 commit comments

Comments
 (0)