Skip to content

Instantly share code, notes, and snippets.

View lucasfeijo's full-sized avatar

Lucas Feijo lucasfeijo

View GitHub Profile

New and Improved Composer™

Bugs we wanna squash from the old composer

  • 677 [macOS] Incorrect placement of text cursor indicator in message input if scrolling triggers
  • 679 [macOS] Adding an emoji in a message sometimes causes the cursor to move before the emoji
  • ??? [both] Incorrect initial size causes views to move and scroll to lag https://stackoverflow.com/questions/74045727/can-i-stop-nsviewrepresentable-layout-lag-for-nstextview
  • ??? [both] When a mention is broken down into two lines, the background color spreads over the whole paragraph
  • ??? [macOS] Undoing a mention only removes it partially (when undo is turned on)
@lucasfeijo
lucasfeijo / focus.swift
Created November 12, 2022 18:16
SwiftUI macOS observe app focus
struct Example: View {
@State private var isWindowActive: Bool = false
var body: some View {
Text("Is Window Active? \(isWindowActive ? "yes" : "no")")
.modifier(WindowStateModifier(isWindowActive: $isWindowActive))
}
}
struct WindowStateModifier: ViewModifier {
@lucasfeijo
lucasfeijo / Error.swift
Created July 14, 2022 19:30
SwiftUI easy Error alert
public extension View {
func alert(title: String? = "Oops", error: Binding<Error?>) -> some View {
alert(isPresented: Binding<Bool>.init(get: {
error.wrappedValue != nil
}, set: { setVal in
if !setVal {
error.wrappedValue = nil
}
})) {
Alert(title: Text(title), message: Text(error.wrappedValue?.localizedDescription ?? ""), dismissButton: .cancel())
@lucasfeijo
lucasfeijo / MIME.swift
Created July 14, 2022 19:26
Get MIME type from Swift Data
public enum MIMEType: String {
case jpeg = "image/jpeg"
case png = "image/png"
case gif = "image/gif"
case tiff = "image/tiff"
case pdf = "application/pdf"
case plainText = "text/plain"
case anyBinary = "application/octet-stream"
}
@lucasfeijo
lucasfeijo / PostponingBuilds.md
Last active January 7, 2021 23:13
Postponing Builds

Postponing builds

Problem

Deploying to mobile isn't as transparent as web: every Connect update nags the user to install it. Continuous delivery like that doesn't offer us the possibility to let builds accumulate until a release, saving user's data and giving us time to rollback when problems arise.

Currently, with our new in-house MDM solution, we don't have a way to control which builds get deployed to Android devices, all builds are consumed by Connect mobile clients as soon as they are uploaded to Nitro and the client downloads them.

Solution

@lucasfeijo
lucasfeijo / Connect RN tech debt wishes.md
Last active July 21, 2020 16:56
Connect RN tech debt wishes

Small

1. Use extracted WebView

  • used in ConnectUrlViewer, this component is now deprecated in RN and needs to be used from here.

2. Use extracted NetInfo

  • is now deprecated and must be used from here.
  • used in three places:
    • Connect (main bookmarks view): checking isConnected before allowing pull down to refresh (is this even needed?)
    • Main: observing connectionChange to start/stop messagebus subscription.
  • Chat: observing connectionChange to start/stop messagebus subscription.
@lucasfeijo
lucasfeijo / FastImagePlaceholder.js
Created July 5, 2019 16:43
react-native-fast-image placeholder wrapper component
import React, { Component } from 'react';
import { Image, View, ViewPropTypes } from 'react-native';
import PropTypes from 'prop-types';
import FastImage from 'react-native-fast-image';
export default class FastImagePlaceholder extends Component {
constructor(props) {
super(props);
this.state = { loaded: false };
}
@lucasfeijo
lucasfeijo / rebuild.sh
Created September 11, 2018 18:03
rebuild
git commit --amend --no-edit && git push --force-with-lease
@lucasfeijo
lucasfeijo / rn-cmds.sh
Last active August 14, 2018 14:12
React Native commands
# `~/Library/Android/sdk/` is my ANDROID_HOME environment variable.
cd $ANDROID_HOME
# Create emulator with 1GB storage on Android SDK 25 called `test`
./tools/bin/avdmanager create avd -n test -k "system-images;android-25;google_apis;x86" -b x86 -c 1000M -d 7 -f
# Run emulator called `test`
./emulator/emulator -avd test
# To run on an android emulator - emulator must be already running