Skip to content

Instantly share code, notes, and snippets.

View hungtrn75's full-sized avatar
🎯
Focusing

Hung Tran hungtrn75

🎯
Focusing
View GitHub Profile
@hungtrn75
hungtrn75 / CustomScrollView.swift
Created October 15, 2020 02:59
Swift: Pull to Refresh
@available(iOS 13.0, *)
public struct CustomScrollView<Content: View>: UIViewRepresentable {
var size: CGSize
var viewBuilder: () -> Content
var handleRefreshControl: () -> Void
public init(@ViewBuilder viewBuilder: @escaping () -> Content, size: CGSize, handleRefreshControl: @escaping () -> Void) {
self.size = size
self.viewBuilder = viewBuilder
@hungtrn75
hungtrn75 / semicircle.dart
Created July 16, 2020 07:29
Flutter clip part of Container to make two semicircle (half circle)
import 'package:flutter/material.dart';
import 'package:vector_math/vector_math.dart' as v_math;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
import React, {Component} from 'react';
import {Dimensions, Platform, StyleSheet} from 'react-native';
import {isIphoneX, getStatusBarHeight} from 'react-native-iphone-x-helper';
import PropTypes from 'prop-types';
/**
* DETECTION AND DIMENSIONS CODE FROM:
* https://github.com/react-community/react-native-safe-area-view
*/
module.exports = {
project: {
android: {
stringsPath: 'app/src/main/res/values/strings.xml',
mainFilePath: 'app/src/main/java/com/your_package_name/MainApplication.java',
},
},
};
import React, { useState } from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import Animated from "react-native-reanimated";
import { timing } from "react-native-redash";
import { colors } from "../../theme";
const tabs = [{ label: "Ng" }, { label: "T" }, { label: "Th" }, { label: "N" }];
const numberTabs = tabs.length;
const { Value, useCode, block, multiply, set } = Animated;
@hungtrn75
hungtrn75 / AndroidManifest.xml
Created March 8, 2020 08:39
React native splash screen android
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.smgboilerplate">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
@hungtrn75
hungtrn75 / V5
Created March 1, 2020 15:56
Issues Navigation
#ReactNavigaionV5
Android: Textinput đẩy bottom tab lên trên.
IOS: bình thường.
Giải pháp: Trong androidManifest set windowSoftInputMode=“adjustPan”
@hungtrn75
hungtrn75 / RecursiveTravaersy
Last active February 29, 2020 19:15
Viết hàm lấy tất cả các Keys/Nested Keys của 1 object.
function flatten(arr) {
let result = [];
for (let item of arr) {
if (Array.isArray(item)) {
result = result.concat(flatten(item));
} else {
result.push(item);
}
}
return result;
import React from "react";
import { StyleSheet } from "react-native";
import Animated, { Easing } from "react-native-reanimated";
import { Block } from "smg-react-native-components";
const loop = loopConfig => {
const { clock, easing, duration, autoStart } = {
clock: new Clock(),
easing: Easing.linear,
duration: 250,
@hungtrn75
hungtrn75 / json
Last active February 6, 2020 09:43
{
"properties": {
"FID": 55,
"District": "Gurugram",
"Development Plan": "Gurgaon-Manesar",
"Controlled Area": "Controlled area around Government Primary School at village Baskusla",
"Village": null,
"Rectangle No.": "44",
"Area": 3665.413,
"Reference": null,