(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// | |
// 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 |
//: 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 |
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. |
// 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) |
/// 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 |
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 |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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 | |
} |
extension Array { | |
func first() -> Element? { | |
if isEmpty { | |
return nil | |
} | |
return self[0] | |
} | |
func last() -> Element? { |