[go: nahoru, domu]

blob: 5842f5f01fe98f0c320a9d04f8129e35d969eeb4 [file] [log] [blame]
Mihai Burlaciuc478fae62019-08-08 10:00:06 +01001/*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Siyamed Sinirfc059292019-11-21 13:39:17 -080017package androidx.ui.framework.samples
Mihai Burlaciuc478fae62019-08-08 10:00:06 +010018
19import androidx.annotation.Sampled
20import androidx.compose.Composable
Qingqing Deng8c5d0382019-09-16 11:59:16 -070021import androidx.ui.core.Alignment
Siyamed Sinirfc059292019-11-21 13:39:17 -080022import androidx.ui.core.DropDownAlignment
23import androidx.ui.core.DropdownPopup
24import androidx.ui.core.Popup
Matvei Malkov59bac362020-02-13 20:23:13 +000025import androidx.ui.foundation.Box
Mihai Burlaciuc478fae62019-08-08 10:00:06 +010026import androidx.ui.foundation.shape.corner.RoundedCornerShape
27import androidx.ui.graphics.Color
Matvei Malkov59bac362020-02-13 20:23:13 +000028import androidx.ui.layout.LayoutSize
George Mount842c8c12020-01-08 16:03:42 -080029import androidx.ui.unit.dp
Mihai Burlaciuc478fae62019-08-08 10:00:06 +010030
31@Sampled
32@Composable
33fun PopupSample() {
Matvei Malkov59bac362020-02-13 20:23:13 +000034 Box {
Mihai Burlaciuc478fae62019-08-08 10:00:06 +010035 val popupWidth = 200.dp
36 val popupHeight = 50.dp
37 val cornerSize = 16.dp
38
39 Popup(alignment = Alignment.Center) {
40 // Draw a rectangle shape with rounded corners inside the popup
Matvei Malkov59bac362020-02-13 20:23:13 +000041 Box(
42 LayoutSize(popupWidth, popupHeight),
43 shape = RoundedCornerShape(cornerSize),
44 backgroundColor = Color.White
45 )
Mihai Burlaciuc478fae62019-08-08 10:00:06 +010046 }
47 }
Mihai Burlaciuc49000c62019-09-17 11:15:47 +010048}
49
50@Sampled
51@Composable
52fun DropdownPopupSample() {
Matvei Malkov59bac362020-02-13 20:23:13 +000053 Box(LayoutSize(400.dp, 200.dp)) {
Mihai Burlaciuc49000c62019-09-17 11:15:47 +010054 val popupWidth = 200.dp
55 val popupHeight = 50.dp
56 val cornerSize = 16.dp
57
58 // The popup will appear below the parent
59 DropdownPopup(dropDownAlignment = DropDownAlignment.Left) {
60 // Draw a rectangle shape with rounded corners inside the popup
Matvei Malkov59bac362020-02-13 20:23:13 +000061 Box(
62 LayoutSize(popupWidth, popupHeight),
63 shape = RoundedCornerShape(cornerSize),
64 backgroundColor = Color.White
65 )
Mihai Burlaciuc49000c62019-09-17 11:15:47 +010066 }
67 }
68}