Skip to content

Instantly share code, notes, and snippets.

@barrault01
barrault01 / CustomColors.swift
Created November 7, 2019 18:33
A enum that implement AppColor protocol to define our colors
import UIKit
enum CustomColors: AppColor {
case primary, secondary
var light: UIColor {
switch self {
case .primary: return UIColor(red: 0, green: 0.8, blue: 0.69, alpha: 1)
case .secondary: return UIColor(red: 219/255, green: 230/255, blue: 228/255, alpha: 1.0)
@barrault01
barrault01 / AppColor.swift
Last active November 9, 2019 01:11
AppColor protocol to Help adding Dark mode in your App
import UIKit
protocol AppColor {
var light: UIColor { get }
var dark: UIColor { get }
var fallbackColorBeforiOS13: UIColor { get }
func color() -> UIColor
}
extension AppColor {
@barrault01
barrault01 / Package.swift
Created June 5, 2019 11:42
Default Package.swift file created with XCode 11
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyFramework",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
@barrault01
barrault01 / CountDownView.swift
Last active September 18, 2020 14:15
View that show a countdown using SwiftUI
import SwiftUI
struct CountDownView : View {
@State var nowDate: Date = Date()
let referenceDate: Date
var timer: Timer {
Timer.scheduledTimer(withTimeInterval: 1, repeats: true) {_ in
self.nowDate = Date()
}
@barrault01
barrault01 / ReactPresenterActivity.java
Created January 2, 2019 12:43
ReactPresenterActivity is an activity that will be responsable of presenting a React Native View
package com.reactnativehelpers.reactpresenter;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.transition.Slide;
import android.view.Gravity;
package com.reactnativehelpers.reactpresenter.presentingPackage;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import java.util.HashMap;
import java.util.Map;
public class PresentingNative extends ReactContextBaseJavaModule {
package com.reactnativehelpers.reactpresenter.presentingPackage;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class MyViewController: UIViewController, ReactPresenter {
...
@IBAction func didTapOnShowReactButton(_ sender: Any) {
self.showReactViewController(moduleName: "MyReactApp",
jsFileName: "main")
}
...
#ifndef Login_Bridging_Header_h
#define Login_Bridging_Header_h
#import <React/RCTBridgeModule.h>
#endif /* Login_Bridging_Header_h */
@barrault01
barrault01 / Podfile
Created December 20, 2018 11:13
LoginDemo Podfile
source 'https://github.com/react-native-helpers/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
target 'LoginDemo' do
use_frameworks!
pod 'Login', path: '../'
# Pods for ValkyrieDemo
target 'LoginDemoTests' do