Skip to content

Instantly share code, notes, and snippets.

View alexeyismirnov's full-sized avatar
💭
Making cool Flutter apps....

Alexey Smirnov alexeyismirnov

💭
Making cool Flutter apps....
  • Hong Kong
View GitHub Profile
@wilsoncusack
wilsoncusack / TextViewExperiment.swift
Created July 8, 2019 21:02
SwiftUI + UITextView with dismiss keyboard button
//
// TextViewExperiment.swift
// Wilson Cusack
//
// Most of the code from https://www.icalvin.dev/post/403
// There's a few changes, but mainly just the ability to close the keyboard.
//
import SwiftUI
import UIKit
@fitomad
fitomad / SwiftUI-flip-animation.swift
Last active October 13, 2020 20:14
A SwiftUI animation that represents a flip view to show Q&A cards.
//: A UIKit based Playground for presenting SwiftUI based user interface
// by @fitomad
import UIKit
import SwiftUI
import PlaygroundSupport
// MARK: - Contenedor Principal -
public struct Container: View
@netsmertia
netsmertia / main.dart
Created May 4, 2018 13:53
flutter image drawing in canvas
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
import 'package:flutter/services.dart' show rootBundle;
import 'dart:async';
import 'dart:typed_data';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@collinjackson
collinjackson / main.dart
Last active November 29, 2022 06:38
Demonstrates scrolling a focused widget into view
// Copyright 2017, the Flutter project authors. Please see the AUTHORS file
// for details. 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:async';
import 'package:meta/meta.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
/// A widget that ensures it is always visible when focused.
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import 'dart:convert';
/*
* TextView with HTML tags support By Kyle Katarn for Dart
*
* Original code by Erik Arvidsson, Mozilla Public License
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
* and ported it on JavaScript by John Resig (ejohn.org)
@kristopherjohnson
kristopherjohnson / findIndex.swift
Last active May 3, 2018 23:03
Swift: Find index of first element of sequence matching a predicate
/// Find the index of the first element of a sequence that satisfies a predicate
///
/// :param: sequence A sequence to be searched
/// :param: predicate A function applied to each element in turn until it returns true
///
/// :returns: Zero-based index of first element that satisfies the predicate, or nil if no such element was found
public func findIndex<S: SequenceType>(sequence: S, predicate: (S.Generator.Element) -> Bool) -> Int? {
for (index, element) in enumerate(sequence) {
if predicate(element) {
return index
@preble
preble / DateRange.swift
Last active July 16, 2019 14:06
Experimenting with creating a SequenceType for iterating over a range of dates. Blogged here: http://adampreble.net/blog/2014/09/iterating-over-range-of-dates-swift/
import Foundation
func > (left: NSDate, right: NSDate) -> Bool {
return left.compare(right) == .OrderedDescending
}
extension NSCalendar {
func dateRange(startDate startDate: NSDate, endDate: NSDate, stepUnits: NSCalendarUnit, stepValue: Int) -> DateRange {
let dateRange = DateRange(calendar: self, startDate: startDate, endDate: endDate, stepUnits: stepUnits, stepValue: stepValue, multiplier: 0)
return dateRange
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@frozzare
frozzare / template.swift
Last active July 24, 2018 15:54
Example of string replacement in Swift with a dictionary
import Foundation
class Template {
class func render (var str: String, dict: Dictionary<String, String>) -> String {
for (key, value) in dict {
str = str.stringByReplacingOccurrencesOfString("{\(key)}", withString: value)
}
return str
}
@calebd
calebd / ArrayHelpers.swift
Last active November 4, 2022 15:17
Swift Helpers
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {