Skip to content

Instantly share code, notes, and snippets.

View nodahikaru's full-sized avatar
🏠
Working from home

Noda Hikaru nodahikaru

🏠
Working from home
View GitHub Profile
import React, { useContext } from 'react'
import { ArrowUp, Download, Star, Trash, X, Edit2 } from 'react-feather'
import { useDispatch, useSelector } from 'react-redux'
import { LabelText } from '@resources/LabelText'
import { TestID } from '@resources/TestID'
import { ContextMenuOption } from '@/components/NoteList/ContextMenuOption'
import { downloadNotes } from '@/utils/helpers'
import {
@nodahikaru
nodahikaru / NotEditor.tsx
Last active June 4, 2020 07:41
Redux hooks
import dayjs from 'dayjs'
import React from 'react'
import { Controlled as CodeMirror } from 'react-codemirror2'
import { useDispatch, useSelector } from 'react-redux'
import { getActiveNote } from '@/utils/helpers'
import { updateNote } from '@/slices/note'
import { togglePreviewMarkdown } from '@/slices/settings'
import { NoteItem } from '@/types'
import { EmptyEditor } from '@/components/Editor/EmptyEditor'
@nodahikaru
nodahikaru / custom_scaffold.dart
Created April 23, 2020 16:43
Fancy Scaffold using Slivers
class CustomScaffold extends StatelessWidget {
const CustomScaffold._({
Key key,
this.title,
this.color,
this.sliverChildDelegate,
this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
this.actions,
this.onRefresh,
}) : super(key: key);
@nodahikaru
nodahikaru / fileupload.dart
Last active April 8, 2020 14:35
File uploading in Flutter/Dart
import 'dart:async';
import 'dart:convert';
import 'dart:core';
import 'dart:io';
import 'package:http/http.dart' as http;
typedef OnUploadProgressCallback = void Function(int sentBytes, int totalBytes);
Future<String> fileUpload({@required File file, OnUploadProgressCallback onUploadProgress}) async {
assert(file != null);
@nodahikaru
nodahikaru / BottomSheetCustom.dart
Created August 26, 2019 03:57
Custom height BottomSheet in Flutter
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
const Duration _kBottomSheetDuration = Duration(milliseconds: 200);
const double _kMinFlingVelocity = 700.0;
const double _kCloseProgressThreshold = 0.5;
@import Photos;
@import AVKit;
[PHPhotoLibrary.sharedPhotoLibrary performChanges:^{
NSURL *url = [NSURL fileURLWithPath:[FileUtil filePath:fileName]];
[PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:url];
} completionHandler:^(BOOL success, NSError * _Nullable error) {
if (error) {
NSLog(@"Error : %@", error);