Skip to content

Commit

Permalink
feat: toolbar (#57)
Browse files Browse the repository at this point in the history
Co-authored-by: Adriel Café <[email protected]>
  • Loading branch information
brenocruzb and adrielcafe authored Oct 14, 2020
1 parent 3ee0cea commit c9a0343
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 14 deletions.
2 changes: 1 addition & 1 deletion detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ style:
active: false
maxJumpCount: 1
MagicNumber:
active: true
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt/,**/*Color.kt"
ignoreNumbers: '-1,0,1,2'
ignoreHashCodeFunction: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,111 @@ package com.jcaique.dialetus.presentation

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.Icon
import androidx.compose.foundation.Text
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Divider
import androidx.compose.material.Scaffold
import androidx.compose.material.TextField
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Search
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.unit.dp
import androidx.ui.tooling.preview.Preview
import com.jcaique.dialetus.presentation.ui.DialetusTheme

class DialetusActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
DialetusTheme {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Greeting("Android")
}
}
App()
}
}
}

@Composable
fun Greeting(name: String) {
Text(text = "Hello $name!")
fun App() {
DialetusTheme {
Scaffold(
topBar = {
AppTop()
},
bodyContent = {
AppContent()
},
bottomBar = {
AppBottom()
}
)
}
}

@Composable
fun AppTop() {
Column {
val query = remember { mutableStateOf("") }

TopAppBar(
title = {
Text(text = "Baianes")
},
backgroundColor = Color.White,
elevation = 0.dp
)
TextField(
value = query.value,
placeholder = {
Text(
text = "Pesquisar",
color = Color.Gray
)
},
leadingIcon = {
Icon(
asset = Icons.Outlined.Search,
tint = Color.Gray
)
},
onValueChange = {
query.value = it
},
modifier = Modifier
.padding(horizontal = 10.dp)
.fillMaxWidth()
.clip(RoundedCornerShape(50)),
backgroundColor = Color.LightGray.copy(alpha = .2f),
activeColor = Color.Transparent
)
Divider(
color = Color.LightGray.copy(alpha = .4f),
thickness = 1.dp,
modifier = Modifier.padding(vertical = 16.dp)
)
}
}

@Composable
fun AppContent() {
// TODO
}

@Composable
fun AppBottom() {
// TODO
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
DialetusTheme {
Greeting("Android")
}
App()
}

0 comments on commit c9a0343

Please sign in to comment.