Giter Club home page Giter Club logo

rentex-jetpack-compose's Introduction

Rentex

Aplicativo de aluguel de carro, consegue visualizar carros,  é datas disponíveis para aluguel. Possui também descrição de cada carro e seus respectivos carros agendados

Feature

  • No início o pensamento foi salvar os dados no Room, depois foi implementado via backend
  • Para salvar uma tabela Room em outra usamos o Embeded , também possui outras relações_
  • Para salvar uma data class pode converter em json
@Entity(tableName = "cars")
data class CarsModel(
    @PrimaryKey
    val carId: UUID = UUID.randomUUID(),
    val brand: String,
    val name: String,
    val about: String,
    @Embedded val rentModel: RentModel, //RentModel era uma entidade do Room
    @ColumnInfo(name = "fuel_type") val fuelType: String,
    val thumbnail: String,
    val accessoriesJson: ArrayList<AccessoriesModel>,
    val photos: ArrayList<String> //maneria de salvar um json dentro do room
)

// precisa usar o converter e nao pode criar genericos

class ArrayListConverter {


    @TypeConverter
    fun fromAccessoriesArrayList(value: ArrayList<AccessoriesModel>): String {
        return Gson().toJson(value)
    }

    @TypeConverter
    fun toAccessoriesArrayList(value: String): ArrayList<AccessoriesModel> {
        return try {
            Gson().fromJson<ArrayList<AccessoriesModel>>(value)
        } catch (e: Exception) {
            arrayListOf()
        }
    }

    @TypeConverter
    fun fromStringArrayList(value: ArrayList<String>): String {

        return Gson().toJson(value)
    }

    @TypeConverter
    fun toStringArrayList(value: String): ArrayList<String> {
        return try {
            Gson().fromJson<ArrayList<String>>(value)
        } catch (e: Exception) {
            arrayListOf()
        }
    }
}


// depois e so usar
        photos = arrayListOf(
            "https://storage.googleapis.com/golden-wind/ignite/react-native/images/15.png",
            "https://storage.googleapis.com/golden-wind/ignite/react-native/images/16.png",
            "https://storage.googleapis.com/golden-wind/ignite/react-native/images/17.png"

        )

  • Alguns hacker que ajuda construir app
//para trabalhar com dots
@Composable
fun Dots(colorApp: Color,modifier: Modifier = Modifier) {
    Canvas(modifier = modifier.size(6.dp)) {
        drawCircle(
            color = colorApp
        )
    }
}

// trabalhar com moeda
val localBrazil = Locale("pt", "BR")
val numberFormat = NumberFormat.getCurrencyInstance(localBrazil)
val currency = numberFormat.format(totalPrice)

//trabalhar com data
val formatDateTime = DateTimeFormatter.ofPattern("dd/MM/yyyy")
val formatString = formatDateTime.format(date)

//multiplicar valores quando e opcional ideal e usar times
parentCarViewModel.selectedCar.value?.rent?.price?.times(
        parentScheduleViewModel.selectionDates.value.size
    )

rentex-jetpack-compose's People

Contributors

kenjimaeda54 avatar kenjimaeda65 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.