Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Oleksandr Leushchenko olexale

🎯
Focusing
View GitHub Profile
@olexale
olexale / maybe_dart.dart
Created January 3, 2022 19:10
Sample for the "Dart Functors, Applicatives, And Monads In Pictures" article
View maybe_dart.dart
void main() {
// Functor
num plus3(num x) => x + 3;
print(Just(2).fmap(plus3)); // Just 5
print(Nothing<num>().fmap(plus3));
print([1,2,3].map((x) => x + 2)); // (3, 4, 5)
final foo = fmap((x) => x + 3, (x) => x + 2);
@olexale
olexale / counter.feature
Created February 28, 2021 10:30
BDD in Flutter article updated feature file
View counter.feature
Feature: Counter
Scenario: Initial counter value is 0
Given the app is running
Then I see {'0'} text
Scenario: Tap the Plus icon increments the counter
Given the app is running
When I tap {Icons.add} icon
Then I see {'1'} text
@olexale
olexale / counter_test.dart
Last active February 28, 2021 10:17
BDD in Flutter article code generated files
View counter_test.dart
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_import, directives_ordering
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import './step/the_app_is_running.dart';
import './step/i_see_text.dart';
void main() {
@olexale
olexale / code_generation.sh
Last active February 28, 2021 11:11
BDD in Flutter article code generation commands
View code_generation.sh
flutter pub run build_runner build - delete-conflicting-outputs
# or
flutter pub run build_runner watch - delete-conflicting-outputs
@olexale
olexale / counter.feature
Created February 28, 2021 10:10
BDD in Flutter article feature file
View counter.feature
Feature: Counter
Scenario: Initial counter value is 0
Given the app is running
Then I see {'0'} text
View ScaryService.cs
public interface IProfileApi
{
 Task<Profile> GetProfile(int id);
 Task<Profile> GetMyProfile();
 Task UpdateMyProfile(Profile profile);
 Task<IEnumerable<Post>> GetPosts(int profile);
}
View TransitionAnimator.cs
public class TransitionAnimator : UIViewControllerAnimatedTransitioning
{
private const double _duration = 0.5;
public CGRect ThumbnailFrame { get; set; }
public UINavigationControllerOperation Operation { get; set; }
public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
{
var presenting = Operation == UINavigationControllerOperation.Push;
View opendetails.cs
private Task OpenDetails(BeatleModel beatle)
{
MessagingCenter.Send<object, int>(this, "TransitionId", beatle.Id);
...
}
View AnimationNavigationControllerDelegate.cs
public class AnimationNavigationControllerDelegate : UINavigationControllerDelegate
{
private TransitionAnimator _animator = new TransitionAnimator();
private int _id;
public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForOperation(UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromViewController, UIViewController toViewController)
{
if (operation == UINavigationControllerOperation.Push)
{
var image = fromViewController.View.ViewWithTag(_id);
View TagEffect.cs
namespace BeatlesApp
{
public class TagEffect : RoutingEffect
{
public TagEffect() : base("BeatlesApp.TagEffect") {}
public static readonly BindableProperty TagProperty =
BindableProperty.CreateAttached("Tag", typeof(int), typeof(TagEffect), 0, propertyChanged: OnTagChanged);
public static int GetTag(BindableObject view)