This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:math'; | |
const SCALE_FRACTION = 0.7; | |
const FULL_SCALE = 1.0; | |
const PAGER_HEIGHT = 200.0; | |
class ItCrowdPage extends StatefulWidget { | |
@override | |
_ItCrowdPageState createState() => _ItCrowdPageState(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flare/flare_actor.dart'; | |
const String ANIM_JUST_NIGHT = "just_night"; | |
const String ANIM_NIGHT_TO_DAY = "night_to_day"; | |
const String ANIM_DAY_TO_NIGHT = "day_to_night"; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: FlareActor("assets/heart.flr", alignment:Alignment.center, fit:BoxFit.contain, animation: "heart",), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun registerAllPersonListener() { | |
MyApp.database?.personDao()?.getAllPeople() | |
?.subscribeOn(Schedulers.io()) | |
?.observeOn(AndroidSchedulers.mainThread()) | |
?.subscribe { listOfPeople -> | |
view.personTableUpdated(listOfPeople) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun addPerson(firstName: String, lastName: String) { | |
val person = Person(0, firstName, lastName) | |
Single.fromCallable { | |
MyApp.database?.personDao()?.insert(person) | |
}.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()).subscribe() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp : Application() { | |
companion object { | |
var database: MyDatabase? = null | |
} | |
override fun onCreate() { | |
super.onCreate() | |
MyApp.database = Room.databaseBuilder(this, MyDatabase::class.java, "we-need-db").build() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Database(entities = arrayOf(Person::class), version = 1) | |
abstract class MyDatabase : RoomDatabase() { | |
abstract fun personDao(): PersonDao | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Dao | |
interface PersonDao { | |
@Query("SELECT * FROM person") | |
fun getAllPeople(): Flowable<List<Person>> | |
@Insert | |
fun insert(person: Person) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
data class Person( | |
@PrimaryKey(autoGenerate = true) | |
val uid: Long, | |
val firstName: String = "", | |
val lastName: String = "" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'kotlin-kapt' | |
android { | |
... | |
} | |
dependencies { | |
... | |
// Room | |
compile 'android.arch.persistence.room:runtime:1.0.0-alpha1' |
NewerOlder