Android app module for Zeichen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

224 lines
10 KiB

  1. package sh.modal.apps.zeichen
  2. import android.os.Bundle
  3. import androidx.activity.ComponentActivity
  4. import androidx.activity.compose.setContent
  5. import androidx.compose.foundation.clickable
  6. import androidx.compose.foundation.layout.Column
  7. import androidx.compose.foundation.layout.padding
  8. import androidx.compose.foundation.layout.size
  9. import androidx.compose.foundation.rememberScrollState
  10. import androidx.compose.foundation.verticalScroll
  11. import androidx.compose.material.*
  12. import androidx.compose.material.icons.Icons
  13. import androidx.compose.material.icons.outlined.Folder
  14. import androidx.compose.material.icons.outlined.Menu
  15. import androidx.compose.material.icons.outlined.Note
  16. import androidx.compose.material.icons.outlined.Search
  17. import androidx.compose.runtime.Composable
  18. import androidx.compose.runtime.rememberCoroutineScope
  19. import androidx.compose.ui.Modifier
  20. import androidx.compose.ui.tooling.preview.Preview
  21. import androidx.compose.ui.unit.dp
  22. import kotlinx.coroutines.launch
  23. import sh.modal.apps.zeichen.components.Navigation
  24. import sh.modal.apps.zeichen.ui.theme.ZeichenTheme
  25. class MainActivity : ComponentActivity() {
  26. @ExperimentalMaterialApi
  27. override fun onCreate(savedInstanceState: Bundle?) {
  28. super.onCreate(savedInstanceState)
  29. setContent {
  30. ZeichenTheme {
  31. // A surface container using the 'background' color from the theme
  32. Surface(color = MaterialTheme.colors.background) {
  33. View()
  34. }
  35. }
  36. }
  37. }
  38. }
  39. @ExperimentalMaterialApi
  40. @Composable
  41. fun View(drawerOpen: Boolean = false) {
  42. val scaffoldState = rememberScaffoldState(drawerState = DrawerState(initialValue = if (drawerOpen) DrawerValue.Open else DrawerValue.Closed ))
  43. val scope = rememberCoroutineScope()
  44. Scaffold(
  45. topBar = {
  46. TopAppBar(
  47. title = { Text("Zeichen") },
  48. navigationIcon = {
  49. IconButton(onClick = {
  50. scope.launch {
  51. scaffoldState.drawerState.open()
  52. }
  53. }) {
  54. Icon(Icons.Outlined.Menu, contentDescription = "Menu")
  55. }
  56. },
  57. actions = {
  58. IconButton(onClick = { /* doSomething() */ }) {
  59. Icon(Icons.Outlined.Search, contentDescription = "Search")
  60. }
  61. },
  62. )
  63. },
  64. bottomBar = {
  65. Navigation()
  66. },
  67. drawerContent = {
  68. Column (
  69. modifier = Modifier.verticalScroll(rememberScrollState())
  70. ) {
  71. Text("Folders", modifier = Modifier.padding(16.dp), style = MaterialTheme.typography.body2)
  72. ListItem(
  73. modifier = Modifier.clickable(enabled = true, onClick = {}),
  74. icon = { Icon(Icons.Outlined.Folder, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  75. text = { Text("Folder 1") },
  76. secondaryText = { Text("5 notes") }
  77. )
  78. Divider(startIndent = 72.dp)
  79. ListItem(
  80. modifier = Modifier.clickable(enabled = true, onClick = {}),
  81. icon = { Icon(Icons.Outlined.Folder, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  82. text = { Text("Folder 2") },
  83. secondaryText = { Text("5 notes") }
  84. )
  85. Divider(startIndent = 72.dp)
  86. ListItem(
  87. modifier = Modifier.clickable(enabled = true, onClick = {}),
  88. icon = { Icon(Icons.Outlined.Folder, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  89. text = { Text("Folder 3") },
  90. secondaryText = { Text("5 notes") }
  91. )
  92. Divider()
  93. Text("Notes", modifier = Modifier.padding(16.dp), style = MaterialTheme.typography.body2)
  94. ListItem (
  95. modifier = Modifier.clickable(enabled = true, onClick = {}),
  96. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  97. singleLineSecondaryText = false,
  98. text = { Text("Note 1") },
  99. secondaryText = { Text("In Material, surfaces in dark themes with higher") },
  100. trailing = { Text("5 mins ago") }
  101. )
  102. Divider(startIndent = 72.dp)
  103. ListItem (
  104. modifier = Modifier.clickable(enabled = true, onClick = {}),
  105. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  106. singleLineSecondaryText = false,
  107. text = { Text("Note 2") },
  108. secondaryText = { Text("This is the note content.") },
  109. trailing = { Text("1 hr ago") }
  110. )
  111. Divider(startIndent = 72.dp)
  112. ListItem (
  113. modifier = Modifier.clickable(enabled = true, onClick = {}),
  114. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  115. singleLineSecondaryText = false,
  116. text = { Text("Note 3") },
  117. secondaryText = { Text("In Material, surfaces in dark themes with higher") },
  118. trailing = { Text("yesterday") }
  119. )
  120. Divider(startIndent = 72.dp)
  121. ListItem (
  122. modifier = Modifier.clickable(enabled = true, onClick = {}),
  123. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  124. singleLineSecondaryText = false,
  125. text = { Text("Note 3") },
  126. secondaryText = { Text("In Material, surfaces in dark themes with higher") },
  127. trailing = { Text("last Wed") }
  128. )
  129. Divider(startIndent = 72.dp)
  130. ListItem (
  131. modifier = Modifier.clickable(enabled = true, onClick = {}),
  132. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  133. singleLineSecondaryText = false,
  134. text = { Text("Note 3") },
  135. secondaryText = { Text("This is the note content.") },
  136. trailing = { Text("last Mon") }
  137. )
  138. Divider(startIndent = 72.dp)
  139. ListItem (
  140. modifier = Modifier.clickable(enabled = true, onClick = {}),
  141. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  142. singleLineSecondaryText = false,
  143. text = { Text("Note 3") },
  144. secondaryText = { Text("This is the note content.") },
  145. trailing = { Text("2 wks ago") }
  146. )
  147. Divider(startIndent = 72.dp)
  148. ListItem (
  149. modifier = Modifier.clickable(enabled = true, onClick = {}),
  150. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  151. singleLineSecondaryText = false,
  152. text = { Text("Note 3") },
  153. secondaryText = { Text("This is the note content.") },
  154. trailing = { Text("1 mo ago") }
  155. )
  156. Divider(startIndent = 72.dp)
  157. ListItem (
  158. modifier = Modifier.clickable(enabled = true, onClick = {}),
  159. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  160. singleLineSecondaryText = false,
  161. text = { Text("Note 3") },
  162. secondaryText = { Text("This is the note content.") },
  163. trailing = { Text("7 mos ago") }
  164. )
  165. Divider(startIndent = 72.dp)
  166. ListItem (
  167. modifier = Modifier.clickable(enabled = true, onClick = { }),
  168. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  169. singleLineSecondaryText = false,
  170. text = { Text("Note 3") },
  171. secondaryText = { Text("This is the note content.") },
  172. trailing = { Text("1 yr ago") }
  173. )
  174. Divider(startIndent = 72.dp)
  175. ListItem (
  176. modifier = Modifier.clickable(enabled = true, onClick = { }),
  177. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  178. singleLineSecondaryText = false,
  179. text = { Text("Note 3") },
  180. secondaryText = { Text("This is the note content.") },
  181. trailing = { Text("5 yrs ago") }
  182. )
  183. Divider(startIndent = 72.dp)
  184. ListItem (
  185. modifier = Modifier.clickable(enabled = true, onClick = {}),
  186. icon = { Icon(Icons.Outlined.Note, modifier = Modifier.size(40.dp), contentDescription = "Folder") },
  187. singleLineSecondaryText = false,
  188. text = { Text("Note 3") },
  189. secondaryText = { Text("This is the note content.") },
  190. trailing = { Text("2010") }
  191. )
  192. }
  193. },
  194. scaffoldState = scaffoldState
  195. ) {
  196. Column(
  197. modifier = Modifier.padding(16.dp)
  198. ) {
  199. Text("hi")
  200. }
  201. }
  202. }
  203. @ExperimentalMaterialApi
  204. @Preview(showBackground = true)
  205. @Composable
  206. fun DefaultPreview() {
  207. ZeichenTheme {
  208. View()
  209. }
  210. }
  211. @ExperimentalMaterialApi
  212. @Preview(showBackground = true)
  213. @Composable
  214. fun WithOpenDrawerPreview() {
  215. ZeichenTheme {
  216. View(true)
  217. }
  218. }