A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix ActionSheet on tablets
ammarahm-edaff38e270c1d
diff --git a/apps/mobile/src/components/ActionSheet/index.js b/apps/mobile/src/components/ActionSheet/index.jsindex b4618376e..2bcd32abf 100644--- a/apps/mobile/src/components/ActionSheet/index.js+++ b/apps/mobile/src/components/ActionSheet/index.js@@ -1,14 +1,30 @@-import PropTypes from "prop-types";-import React, { Component, createRef } from "react";-import { Animated, DeviceEventEmitter, Dimensions, FlatList, Keyboard, Modal, Platform, StatusBar, TextInput,findNodeHandle, TouchableOpacity, UIManager, View, ViewPropTypes } from "react-native";-import { styles } from "./styles";+import PropTypes from 'prop-types';+import React, {Component, createRef} from 'react';+import {+ Animated,+ DeviceEventEmitter,+ Dimensions,+ FlatList,+ Keyboard,+ Modal,+ Platform,+ StatusBar,+ TextInput,+ findNodeHandle,+ TouchableOpacity,+ UIManager,+ View,+ ViewPropTypes,+} from 'react-native';+import {w} from '../../utils/utils';+import {styles} from './styles';var deviceHeight = getDeviceHeight();function getDeviceHeight(statusBarTranslucent) {- var height = Dimensions.get("window").height;+ var height = Dimensions.get('window').height;- if (Platform.OS === "android" && !statusBarTranslucent) {+ if (Platform.OS === 'android' && !statusBarTranslucent) {return height - StatusBar.currentHeight;}@@ -18,19 +34,19 @@ function getDeviceHeight(statusBarTranslucent) {const getElevation = (elevation) => {return {elevation,- shadowColor: "black",- shadowOffset: { width: 0.3 * elevation, height: 0.5 * elevation },+ shadowColor: 'black',+ shadowOffset: {width: 0.3 * elevation, height: 0.5 * elevation},shadowOpacity: 0.2,shadowRadius: 0.7 * elevation,};};const SUPPORTED_ORIENTATIONS = [- "portrait",- "portrait-upside-down",- "landscape",- "landscape-left",- "landscape-right",+ 'portrait',+ 'portrait-upside-down',+ 'landscape',+ 'landscape-left',+ 'landscape-right',];export default class ActionSheet extends Component {@@ -130,12 +146,12 @@ export default class ActionSheet extends Component {},() => {this.isClosing = false;- DeviceEventEmitter.emit("hasReachedTop", false);+ DeviceEventEmitter.emit('hasReachedTop', false);if (closable) {this.layoutHasCalled = false;- if (typeof onClose === "function") onClose();+ if (typeof onClose === 'function') onClose();}- }+ },);});}@@ -192,7 +208,7 @@ export default class ActionSheet extends Component {extraScroll: this.customComponentHeight + addFactor + extraScroll;- if (Platform.OS === "ios") {+ if (Platform.OS === 'ios') {await this.waitAsync(delayActionSheetDrawTime);} else {if (delayActionSheetDraw) {@@ -202,7 +218,7 @@ export default class ActionSheet extends Component {this._scrollTo(scrollOffset, false);- if (Platform.OS === "ios") {+ if (Platform.OS === 'ios') {await this.waitAsync(delayActionSheetDrawTime / 2);} else {if (delayActionSheetDraw) {@@ -213,7 +229,7 @@ export default class ActionSheet extends Component {this._openAnimation(scrollOffset);if (!gestureEnabled) {- DeviceEventEmitter.emit("hasReachedTop");+ DeviceEventEmitter.emit('hasReachedTop');}this.layoutHasCalled = true;@@ -221,7 +237,7 @@ export default class ActionSheet extends Component {};_openAnimation = (scrollOffset) => {- let { bounciness, bounceOnOpen, animated, openAnimationSpeed } = this.props;+ let {bounciness, bounceOnOpen, animated, openAnimationSpeed} = this.props;if (animated) {this.transformValue.setValue(scrollOffset);@@ -250,7 +266,7 @@ export default class ActionSheet extends Component {};_onScrollEnd = async (event) => {- let { springOffset, extraScroll } = this.props;+ let {springOffset, extraScroll} = this.props;let verticalOffset = event.nativeEvent.contentOffset.y;@@ -270,7 +286,7 @@ export default class ActionSheet extends Component {await this.waitAsync(300);this.isRecoiling = false;- DeviceEventEmitter.emit("hasReachedTop", true);+ DeviceEventEmitter.emit('hasReachedTop', true);} else {this._scrollTo(this.prevScroll);}@@ -333,9 +349,9 @@ export default class ActionSheet extends Component {let offsetY = event.nativeEvent.contentOffset.y;let addFactor = deviceHeight * 0.1;if (this.customComponentHeight + addFactor - offsetY < 50) {- DeviceEventEmitter.emit("hasReachedTop", true);+ DeviceEventEmitter.emit('hasReachedTop', true);} else {- DeviceEventEmitter.emit("hasReachedTop", false);+ DeviceEventEmitter.emit('hasReachedTop', false);}};@@ -351,13 +367,13 @@ export default class ActionSheet extends Component {componentDidMount() {Keyboard.addListener(- Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow",- this._onKeyboardShow+ Platform.OS === 'android' ? 'keyboardDidShow' : 'keyboardWillShow',+ this._onKeyboardShow,);Keyboard.addListener(- Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide",- this._onKeyboardHide+ Platform.OS === 'android' ? 'keyboardDidHide' : 'keyboardWillHide',+ this._onKeyboardHide,);}@@ -365,14 +381,14 @@ export default class ActionSheet extends Component {this.setState({keyboard: true,});- const ReactNativeVersion = require("react-native/Libraries/Core/ReactNativeVersion");+ const ReactNativeVersion = require('react-native/Libraries/Core/ReactNativeVersion');let v = ReactNativeVersion.version.major + ReactNativeVersion.version.minor;v = parseInt(v);- if (v >= 63 || Platform.OS === "ios") {+ if (v >= 63 || Platform.OS === 'ios') {let keyboardHeight = e.endCoordinates.height;- const { height: windowHeight } = Dimensions.get("window");+ const {height: windowHeight} = Dimensions.get('window');const currentlyFocusedField = TextInput.State.currentlyFocusedInput? findNodeHandle(TextInput.State.currentlyFocusedInput())@@ -393,7 +409,7 @@ export default class ActionSheet extends Component {duration: 250,useNativeDriver: true,}).start();- }+ },);} else {Animated.timing(this.transformValue, {@@ -417,18 +433,18 @@ export default class ActionSheet extends Component {componentWillUnmount() {Keyboard.removeListener(- Platform.OS === "android" ? "keyboardDidShow" : "keyboardWillShow",- this._onKeyboardShow+ Platform.OS === 'android' ? 'keyboardDidShow' : 'keyboardWillShow',+ this._onKeyboardShow,);Keyboard.removeListener(- Platform.OS === "android" ? "keyboardDidHide" : "keyboardWillHide",- this._onKeyboardHide+ Platform.OS === 'android' ? 'keyboardDidHide' : 'keyboardWillHide',+ this._onKeyboardHide,);}render() {- let { scrollable, modalVisible, keyboard } = this.state;+ let {scrollable, modalVisible, keyboard} = this.state;let {onOpen,overlayColor,@@ -455,19 +471,15 @@ export default class ActionSheet extends Component {onShow={onOpen}onRequestClose={this._onRequestClose}transparent={true}- statusBarTranslucent={statusBarTranslucent}- >---+ statusBarTranslucent={statusBarTranslucent}><Animated.Viewstyle={[styles.parentContainer,{opacity: this.opacityValue,+ width: '100%',},- ]}- >+ ]}><FlatListbounces={false}keyboardShouldPersistTaps={keyboardShouldPersistTaps}@@ -482,21 +494,27 @@ export default class ActionSheet extends Component {onTouchEnd={this._onTouchEnd}onScroll={this._onScroll}style={styles.scrollView}- data={["dummy"]}+ contentContainerStyle={{+ width: w,+ }}+ data={['dummy']}keyExtractor={(item) => item}- renderItem={({ item, index }) => (- <View>+ renderItem={({item, index}) => (+ <View+ style={{+ width: '100%',+ }}><Animated.ViewonTouchStart={this._onTouchBackdrop}onTouchMove={this._onTouchBackdrop}onTouchEnd={this._onTouchBackdrop}style={{- height: "100%",- width: "100%",- opacity: defaultOverlayOpacity,- position: "absolute",- backgroundColor: overlayColor,+ height: '100%',+ width: '100%',+ position: 'absolute',zIndex: 1,+ backgroundColor: overlayColor,+ opacity: defaultOverlayOpacity,}}/><View@@ -505,16 +523,15 @@ export default class ActionSheet extends Component {onTouchEnd={this._onTouchEnd}style={{height: deviceHeight * 1.1,- width: "100%",+ width: '100%',zIndex: 10,- }}- >+ }}><TouchableOpacityonPress={this._onTouchBackdrop}onLongPress={this._onTouchBackdrop}style={{height: deviceHeight * 1.1,- width: "100%",+ width: '100%',}}/></View>@@ -534,8 +551,7 @@ export default class ActionSheet extends Component {},],},- ]}- >+ ]}>{gestureEnabled || headerAlwaysVisible ? (CustomHeaderComponent ? (CustomHeaderComponent@@ -543,7 +559,7 @@ export default class ActionSheet extends Component {<Viewstyle={[styles.indicator,- { backgroundColor: indicatorColor },+ {backgroundColor: indicatorColor},]}/>)@@ -553,15 +569,14 @@ export default class ActionSheet extends Component {<Viewstyle={[{- width: "100%",- backgroundColor: "transparent",+ width: '100%',+ backgroundColor: 'transparent',},footerStyle,{height: footerHeight,},- ]}- >+ ]}>{CustomFooterComponent}</View></Animated.View>@@ -569,7 +584,6 @@ export default class ActionSheet extends Component {)}/></Animated.View>-</Modal>);}@@ -597,15 +611,15 @@ ActionSheet.defaultProps = {springOffset: 100,elevation: 5,initialOffsetFromBottom: 1,- indicatorColor: "#f0f0f0",+ indicatorColor: '#f0f0f0',defaultOverlayOpacity: 0.3,- overlayColor: "black",+ overlayColor: 'black',closable: true,bottomOffset: 0,closeOnTouchBackdrop: true,onClose: () => {},onOpen: () => {},- keyboardShouldPersistTaps: "never",+ keyboardShouldPersistTaps: 'never',statusBarTranslucent: true,};ActionSheet.propTypes = {@@ -638,6 +652,6 @@ ActionSheet.propTypes = {overlayColor: PropTypes.string,onClose: PropTypes.func,onOpen: PropTypes.func,- keyboardShouldPersistTaps: PropTypes.oneOf(["always", "default", "never"]),+ keyboardShouldPersistTaps: PropTypes.oneOf(['always', 'default', 'never']),statusBarTranslucent: PropTypes.bool,};diff --git a/apps/mobile/src/components/ActionSheet/styles.js b/apps/mobile/src/components/ActionSheet/styles.jsindex b08b71ab9..2cc9eada9 100644--- a/apps/mobile/src/components/ActionSheet/styles.js+++ b/apps/mobile/src/components/ActionSheet/styles.js@@ -1,9 +1,10 @@import {StyleSheet} from 'react-native';+import { w } from '../../utils/utils';export const styles = StyleSheet.create({scrollview: {height: '100%',- width: '100%',+ width: w,backgroundColor: 'transparent',},container: {diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.jsindex 5f9242735..7125f1b7e 100644--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@ -634,7 +634,6 @@ export const ActionSheetComponent = ({style={{paddingBottom: 30,backgroundColor: colors.bg,- width: w,paddingHorizontal: 0,}}>{!note.id && !note.dateCreated ? (