Skip to content

Instantly share code, notes, and snippets.

View JorgeCastilloPrz's full-sized avatar
🎉
Mostly Android stuff now, also FP

Jorge Castillo JorgeCastilloPrz

🎉
Mostly Android stuff now, also FP
View GitHub Profile
final Animatable<double> _kStrokeHeadTween = CurveTween(
curve: const Interval(0.0, 0.5, curve: Curves.fastOutSlowIn),
).chain(CurveTween(
curve: const SawTooth(5),
));
@JorgeCastilloPrz
JorgeCastilloPrz / ArcPainter4.dart
Created June 4, 2019 17:19
Complete Paint method.
class ArcPainter extends CustomPainter {
// ...
@override
void paint(Canvas canvas, Size size) {
if (backgroundColor != null) {
final Paint backgroundPaint = Paint()
..color = backgroundColor
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke;
@JorgeCastilloPrz
JorgeCastilloPrz / ArcPainter3.dart
Created May 29, 2019 21:29
ArcPainter, rendering background colored circle.
class ArcPainter extends CustomPainter {
// ...
@override
void paint(Canvas canvas, Size size) {
if (backgroundColor != null) {
final Paint backgroundPaint = Paint()
..color = backgroundColor
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke;
@JorgeCastilloPrz
JorgeCastilloPrz / ArcPainter2.dart
Created May 29, 2019 21:27
ArcPainter with overriden paint method.
class ArcPainter extends CustomPainter {
ArcPainter({
this.strokeWidth,
this.backgroundColor,
this.valueColor,
this.headValue,
this.tailValue,
this.stepValue,
this.rotationValue
})
@JorgeCastilloPrz
JorgeCastilloPrz / ArcPainter1.dart
Last active May 29, 2019 21:16
CustomPainter declaration
class ArcPainter extends CustomPainter {
ArcPainter({
this.strokeWidth,
this.backgroundColor,
this.valueColor,
this.headValue,
this.tailValue,
this.stepValue,
this.rotationValue
})
@JorgeCastilloPrz
JorgeCastilloPrz / GroupRepository.kt
Created April 10, 2019 13:34
Keep87Sample project
package com.data.instances
import com.data.Repository
import com.domain.Group
import com.domain.User
extension class GroupRepository(with val userRepository: Repository<User>) : Repository<Group> {
override fun loadAll(): List<Group> {
return listOf(Group(userRepository.loadAll()))
}
@JorgeCastilloPrz
JorgeCastilloPrz / blogpostdraft.md
Last active December 11, 2018 14:41
blogpost draft

Exploring Material Components

Initial thoughts

Not long ago a new version of the Material Design Guidelines was published by Google, and that came along with enhanced support for integration of the principles to the community. This included other interesting resources like some fancy sample projects mimicking real world apps called Material Studies, a brand new Sketch plugin for generating Material themes and styles, and a new Material Components library that intents to replace the old Design Support Library, among other initiatives.

As you probably have heard of, in terms of Android, Android Support Library 28 will be the last version deployed ever, and we'll move directly into the AndroidX APIs (JetPack) once for

@JorgeCastilloPrz
JorgeCastilloPrz / PolymorphicDeferredTest2.kt
Created July 31, 2018 11:41
PolymorphicDeferredTest2.kt
object test {
@JvmStatic
fun main(args: Array<String>): Unit {
val user1 = User(UserId("user1"))
val user2 = User(UserId("user2"))
val user3 = User(UserId("unknown user"))
val deferredModuleAlt = Module(DeferredK.async())
deferredModuleAlt.run {
@JorgeCastilloPrz
JorgeCastilloPrz / allTasksByUserAsync.kt
Last active July 31, 2018 11:32
allTasksByUserAsync.kt
override fun allTasksByUser(user: User): Kind<F, List<Task>> =
async { callback: (Either<Throwable, List<Task>>) -> Unit ->
Option.fromNullable(internetStorage[user]).fold(
{ callback(UserNotInRemoteStorage(user).left()) },
{ callback(it.right()) }
)
}
@JorgeCastilloPrz
JorgeCastilloPrz / PolymorphicRemoteDataSource.kt
Last active July 31, 2018 11:31
PolymorphicRemoteDataSource.kt
class RemoteDataSource<F>(A: Async<F>) : DataSource<F>, Async<F> by A {
private val internetStorage: Map<User, List<Task>> =
mapOf(User(UserId("user2")) to listOf(Task("Remote Task assigned to user2")))
override fun allTasksByUser(user: User): Kind<F, List<Task>> =
async { callback: (Either<Throwable, List<Task>>) -> Unit ->
Option.fromNullable(internetStorage[user]).fold(
{ callback(UserNotInRemoteStorage(user).left()) },
{ callback(it.right()) }
)