Skip to content

Instantly share code, notes, and snippets.

View IhorKlimov's full-sized avatar

Ihor Klimov IhorKlimov

View GitHub Profile
@IhorKlimov
IhorKlimov / bottom_sheet_example.dart
Last active February 27, 2019 07:39
Flutter Bottom Sheet
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
/// A [FormField] that contains a [BetterTextField].
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:collection';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
@IhorKlimov
IhorKlimov / introrx.md
Created January 19, 2018 11:54 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@IhorKlimov
IhorKlimov / build.gradle
Created May 5, 2017 05:40
Android Gradle Plugin for defining default wrap_content width/height attributes for views in layout. No need to declare those. Works with Data Binding now only. Add this code to your module's build.gradle and you'll get it automatically
apply plugin: 'com.google.gms.google-services'
class DefaultAttributesPlugin implements Plugin<Project> {
void apply(Project project) {
project.afterEvaluate {
def task = project.task('checkAttributes', type: DefaultAttributes)
project.android.applicationVariants.all { variant ->
project.tasks."dataBindingProcessLayouts${capitalizeFirstLetter(variant.flavorName)}${capitalizeFirstLetter(variant.buildType.name)}".doLast {
task.execute()
@IhorKlimov
IhorKlimov / Getter Ignore m Prefix
Created February 2, 2017 22:56
Android Studio Getter/Setter Ignore m Prefix Templates
#if($field.modifierStatic)
static ##
#end
$field.type ##
#set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project))))
#if ($field.boolean && $field.primitive)
#if ($StringUtil.startsWithIgnoreCase($name, 'is'))
#set($name = $StringUtil.decapitalize($name))
#else
is##
<#if applicationPackage??>
import ${applicationPackage}.databinding.${fragmentLayoutName?replace('_', ' ')?capitalize?replace(' ','')}Binding;
</#if>
<#if applicationPackage??>
import ${applicationPackage}.databinding.${fragment_layout?replace('_', ' ')?capitalize?replace(' ','')}Binding;
</#if>
public class ViewHolder extends RecyclerView.ViewHolder {
${fragment_layout?replace('_', ' ')?capitalize?replace(' ','')}Binding binding;
public ViewHolder(View view) {
super(view);
binding = DataBindingUtil.bind(view);
}
}
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.binding.setItem(mValues.get(position));
holder.binding.getRoot().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.