Skip to content

Commit 02ed887

Browse files
committed
Add sample
1 parent 49478a1 commit 02ed887

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

sample/src/main/java/com/ceribe/compose/sample/MainActivity.kt

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
package com.ceribe.compose.sample
22

3+
import android.content.Context
34
import android.os.Bundle
5+
import android.widget.Toast
46
import androidx.activity.ComponentActivity
57
import androidx.activity.compose.setContent
68
import androidx.compose.animation.*
79
import androidx.compose.foundation.layout.fillMaxSize
8-
import androidx.compose.material.MaterialTheme
9-
import androidx.compose.material.Surface
10+
import androidx.compose.material.*
11+
import androidx.compose.material.icons.Icons
12+
import androidx.compose.material.icons.filled.Delete
13+
import androidx.compose.material.icons.filled.Edit
14+
import androidx.compose.material.icons.filled.List
15+
import androidx.compose.runtime.Composable
1016
import androidx.compose.ui.Modifier
17+
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.platform.LocalContext
19+
import com.ceribe.compose.overflowmenu.OverflowMenu
1120
import com.ceribe.compose.sample.ui.theme.SampleTheme
1221

1322
@ExperimentalAnimationApi
@@ -21,8 +30,49 @@ class MainActivity : ComponentActivity() {
2130
modifier = Modifier.fillMaxSize(),
2231
color = MaterialTheme.colors.background
2332
) {
33+
Sample1()
2434
}
2535
}
2636
}
2737
}
38+
}
39+
40+
fun Context.toast(message: CharSequence) =
41+
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
42+
43+
@Composable
44+
fun Sample1() {
45+
val context = LocalContext.current
46+
Scaffold(
47+
topBar = {
48+
TopAppBar(
49+
title = { Text("Sample 1") },
50+
actions = {
51+
OverflowMenu {
52+
shownIconsCount = 2
53+
icons {
54+
icon {
55+
imageVector = Icons.Filled.Edit
56+
onClick = { context.toast("First Icon Clicked") }
57+
}
58+
icon {
59+
imageVector = Icons.Filled.Delete
60+
onClick = { context.toast("Second Icon Clicked") }
61+
}
62+
icon {
63+
label = "Third Example"
64+
onClick = { context.toast("Third Icon Clicked") }
65+
}
66+
}
67+
defaults {
68+
tint = Color.Red
69+
}
70+
overflowIcon {
71+
tint = Color.Yellow
72+
}
73+
}
74+
}
75+
)
76+
}
77+
) {}
2878
}

0 commit comments

Comments
 (0)