diff --git a/src/App.js b/src/App.js index 57882fe4..e24860bb 100644 --- a/src/App.js +++ b/src/App.js @@ -85,7 +85,7 @@ const AppDrawerStack = createDrawerNavigator( /** We have to return something. */ return NavigationActions.setParams({ params: { dummy: true }, - key: route.key, + key: route.key }); } }; @@ -120,7 +120,7 @@ const AppDrawer = createStackNavigator( [SCREEN_INPUT_MODAL]: InputModalStack, [SCREEN_AUTHENTICATE]: AuthenticateModalStack, [SCREEN_MANAGE_PRIVILEGES]: ManagePrivilegesStack, - [SCREEN_KEY_RECOVERY]: KeyRecoveryStack, + [SCREEN_KEY_RECOVERY]: KeyRecoveryStack }, { mode: 'modal', diff --git a/src/global.js b/src/global.js index 37bebdd5..a77078f5 100644 --- a/src/global.js +++ b/src/global.js @@ -26,7 +26,7 @@ import { SFPrivilegesManager } from 'standard-file-js'; -SFItem.AppDomain = "org.standardnotes.sn"; +SFItem.AppDomain = 'org.standardnotes.sn'; global.SFItem = SFItem; global.SFItemParams = SFItemParams; @@ -38,16 +38,10 @@ global.SFHttpManager = SFHttpManager; global.SFAuthManager = SFAuthManager; global.SFPrivilegesManager = SFPrivilegesManager; -import SF from "./lib/sfjs/sfjs" +import SF from './lib/sfjs/sfjs'; global.SFJS = SF.get(); -import { - SNNote, - SNTag, - SNTheme, - SNComponent, - SNComponentManager -} from 'snjs'; +import { SNNote, SNTag, SNTheme, SNComponent, SNComponentManager } from 'snjs'; global.SNNote = SNNote; global.SNTag = SNTag; diff --git a/src/style/ActionSheetWrapper.js b/src/style/ActionSheetWrapper.js index d4f95719..350acf80 100644 --- a/src/style/ActionSheetWrapper.js +++ b/src/style/ActionSheetWrapper.js @@ -1,27 +1,28 @@ -import React, {Component} from 'react'; -import { StyleSheet, StatusBar, Alert, Platform, Dimensions } from 'react-native'; -import StyleKit from "@Style/StyleKit" -import ActionSheet from 'react-native-actionsheet' -import ApplicationState from "@Lib/ApplicationState" +import React from 'react'; +import { StyleSheet } from 'react-native'; +import ActionSheet from 'react-native-actionsheet'; +import ApplicationState from '@Lib/ApplicationState'; +import StyleKit from '@Style/StyleKit'; export default class ActionSheetWrapper { - - static BuildOption({text, key, callback, destructive}) { + static BuildOption({ text, key, callback, destructive }) { return { text, key, callback, destructive - } + }; } - constructor({title, options, onCancel}) { - options.push({text: "Cancel", callback: onCancel}); + constructor({ title, options, onCancel }) { + options.push({ text: 'Cancel', callback: onCancel }); this.options = options; - this.destructiveIndex = this.options.indexOf(this.options.find((candidate) => { - return candidate.destructive; - })) + this.destructiveIndex = this.options.indexOf( + this.options.find(candidate => { + return candidate.destructive; + }) + ); this.cancelIndex = this.options.length - 1; this.title = title; } @@ -30,44 +31,47 @@ export default class ActionSheetWrapper { this.actionSheet.show(); } - handleActionSheetPress = (index) => { + handleActionSheetPress = index => { let option = this.options[index]; option.callback && option.callback(option); - } + }; actionSheetElement() { return ( this.actionSheet = o} + ref={o => (this.actionSheet = o)} title={this.title} - options={this.options.map((option) => {return option.text})} + options={this.options.map(option => { + return option.text; + })} cancelButtonIndex={this.cancelIndex} destructiveButtonIndex={this.destructiveIndex} onPress={this.handleActionSheetPress} {...ActionSheetWrapper.actionSheetStyles()} /> - ) + ); } static actionSheetStyles() { return { wrapperStyle: StyleKit.styles.actionSheetWrapper, overlayStyle: StyleKit.styles.actionSheetOverlay, - bodyStyle : StyleKit.styles.actionSheetBody, + bodyStyle: StyleKit.styles.actionSheetBody, buttonWrapperStyle: StyleKit.styles.actionSheetButtonWrapper, buttonTitleStyle: StyleKit.styles.actionSheetButtonTitle, titleWrapperStyle: StyleKit.styles.actionSheetTitleWrapper, titleTextStyle: StyleKit.styles.actionSheetTitleText, - tintColor: ApplicationState.isIOS ? undefined : StyleKit.variable("stylekitInfoColor"), + tintColor: ApplicationState.isIOS + ? undefined + : StyleKit.variables.stylekitInfoColor, - buttonUnderlayColor: StyleKit.variable("stylekitBorderColor"), + buttonUnderlayColor: StyleKit.variables.stylekitBorderColor, cancelButtonWrapperStyle: StyleKit.styles.actionSheetCancelButtonWrapper, cancelButtonTitleStyle: StyleKit.styles.actionSheetCancelButtonTitle, cancelMargin: StyleSheet.hairlineWidth - } + }; } - } diff --git a/src/style/AndroidTextFix.js b/src/style/AndroidTextFix.js index 14e751a4..9b2591c8 100644 --- a/src/style/AndroidTextFix.js +++ b/src/style/AndroidTextFix.js @@ -9,15 +9,15 @@ const React = require('react'); const { Platform, Text } = require('react-native'); const defaultFontFamily = { - ...Platform.select({ - android: { fontFamily: 'Roboto' } - }) + ...Platform.select({ + android: { fontFamily: 'Roboto' } + }) }; const oldRender = Text.render; Text.render = function(...args) { - const origin = oldRender.call(this, ...args); - return React.cloneElement(origin, { - style: [defaultFontFamily, origin.props.style] - }); + const origin = oldRender.call(this, ...args); + return React.cloneElement(origin, { + style: [defaultFontFamily, origin.props.style] + }); }; diff --git a/src/style/StyleKit.js b/src/style/StyleKit.js index 830ffec9..4e1c165a 100644 --- a/src/style/StyleKit.js +++ b/src/style/StyleKit.js @@ -10,7 +10,7 @@ import { keyboardColorForTheme, LIGHT_CONTENT, DARK_CONTENT, - LIGHT_MODE_KEY, + LIGHT_MODE_KEY } from '@Style/utils'; import ThemeDownloader from '@Style/Util/ThemeDownloader'; @@ -115,12 +115,12 @@ export default class StyleKit { { variables: THEME_BLUE_JSON, name: 'Blue', - isInitial: true, + isInitial: true }, { variables: THEME_RED_JSON, - name: 'Red', - }, + name: 'Red' + } ]; for (const option of options) { @@ -139,10 +139,10 @@ export default class StyleKit { dock_icon: { type: 'circle', background_color: variables.stylekitInfoColor, - border_color: variables.stylekitInfoColor, - }, - }, - }, + border_color: variables.stylekitInfoColor + } + } + } }); this.systemThemes.push(theme); @@ -156,7 +156,7 @@ export default class StyleKit { ThemeManager.get().setThemeForMode({ mode: currentMode, - theme: defaultTheme, + theme: defaultTheme }); this.setActiveTheme(defaultTheme); @@ -183,7 +183,7 @@ export default class StyleKit { this.setActiveTheme(newTheme); } catch (e) { - console.error("Error parsing initial theme", e); + console.error('Error parsing initial theme', e); return runDefaultTheme(); } } @@ -289,7 +289,10 @@ export default class StyleKit { .downloadTheme(theme) .then(variables => { if (!variables) { - Alert.alert("Not Available", "This theme is not available on mobile."); + Alert.alert( + 'Not Available', + 'This theme is not available on mobile.' + ); return; } @@ -327,7 +330,7 @@ export default class StyleKit { /** No matching theme found, set currently active theme as the default. */ this.assignThemeForMode({ theme: this.activeTheme, - mode: this.currentDarkMode, + mode: this.currentDarkMode }); } } @@ -355,35 +358,35 @@ export default class StyleKit { const { mainTextFontSize, paddingLeft } = this.constants; this.styles = { baseBackground: { - backgroundColor: variables.stylekitBackgroundColor, + backgroundColor: variables.stylekitBackgroundColor }, contrastBackground: { - backgroundColor: variables.stylekitContrastBackgroundColor, + backgroundColor: variables.stylekitContrastBackgroundColor }, container: { flex: 1, - height: '100%', + height: '100%' }, flexContainer: { flex: 1, - flexDirection: 'column', + flexDirection: 'column' }, centeredContainer: { flex: 1, flexDirection: 'column', justifyContent: 'center', - alignItems: 'center', + alignItems: 'center' }, flexedItem: { - flexGrow: 1, + flexGrow: 1 }, uiText: { color: variables.stylekitForegroundColor, - fontSize: mainTextFontSize, + fontSize: mainTextFontSize }, view: {}, @@ -393,7 +396,7 @@ export default class StyleKit { tableSection: { marginTop: 10, marginBottom: 10, - backgroundColor: variables.stylekitBackgroundColor, + backgroundColor: variables.stylekitBackgroundColor }, sectionedTableCell: { @@ -403,25 +406,25 @@ export default class StyleKit { paddingRight: paddingLeft, paddingTop: 13, paddingBottom: 12, - backgroundColor: variables.stylekitBackgroundColor, + backgroundColor: variables.stylekitBackgroundColor }, textInputCell: { maxHeight: 50, paddingTop: 0, - paddingBottom: 0, + paddingBottom: 0 }, sectionedTableCellTextInput: { fontSize: mainTextFontSize, padding: 0, color: variables.stylekitForegroundColor, - height: '100%', + height: '100%' }, sectionedTableCellFirst: { borderTopColor: variables.stylekitBorderColor, - borderTopWidth: 1, + borderTopWidth: 1 }, sectionedTableCellLast: {}, @@ -430,20 +433,20 @@ export default class StyleKit { paddingTop: 0, paddingBottom: 0, minHeight: 47, - backgroundColor: 'transparent', + backgroundColor: 'transparent' }, sectionedAccessoryTableCellLabel: { fontSize: mainTextFontSize, color: variables.stylekitForegroundColor, - minWidth: '80%', + minWidth: '80%' }, buttonCell: { paddingTop: 0, paddingBottom: 0, flex: 1, - justifyContent: 'center', + justifyContent: 'center' }, buttonCellButton: { @@ -453,11 +456,11 @@ export default class StyleKit { Platform.OS === 'android' ? variables.stylekitForegroundColor : variables.stylekitInfoColor, - fontSize: mainTextFontSize, + fontSize: mainTextFontSize }, buttonCellButtonLeft: { - textAlign: 'left', + textAlign: 'left' }, noteText: { @@ -468,17 +471,17 @@ export default class StyleKit { paddingLeft: paddingLeft, paddingRight: paddingLeft, paddingBottom: 10, - backgroundColor: variables.stylekitBackgroundColor, + backgroundColor: variables.stylekitBackgroundColor }, noteTextIOS: { paddingLeft: paddingLeft - 5, - paddingRight: paddingLeft - 5, + paddingRight: paddingLeft - 5 }, noteTextNoPadding: { paddingLeft: 0, - paddingRight: 0, + paddingRight: 0 }, actionSheetWrapper: {}, @@ -493,47 +496,47 @@ export default class StyleKit { * This will also set button border bottoms, since margin is used * instead of borders */ - backgroundColor: variables.stylekitBorderColor, + backgroundColor: variables.stylekitBorderColor }, actionSheetTitleWrapper: { backgroundColor: variables.stylekitBackgroundColor, - marginBottom: 1, + marginBottom: 1 }, actionSheetTitleText: { color: variables.stylekitForegroundColor, - opacity: 0.5, + opacity: 0.5 }, actionSheetButtonWrapper: { backgroundColor: variables.stylekitBackgroundColor, - marginTop: 0, + marginTop: 0 }, actionSheetButtonTitle: { - color: variables.stylekitForegroundColor, + color: variables.stylekitForegroundColor }, actionSheetCancelButtonWrapper: { - marginTop: 0, + marginTop: 0 }, actionSheetCancelButtonTitle: { color: variables.stylekitInfoColor, - fontWeight: 'normal', + fontWeight: 'normal' }, bold: { - fontWeight: 'bold', - }, + fontWeight: 'bold' + } }; } buildConstants() { this.constants = { mainTextFontSize: 16, - paddingLeft: 14, + paddingLeft: 14 }; } diff --git a/src/style/Util/ThemeDownloader.js b/src/style/Util/ThemeDownloader.js index 081cc0e1..e09b172b 100644 --- a/src/style/Util/ThemeDownloader.js +++ b/src/style/Util/ThemeDownloader.js @@ -1,10 +1,8 @@ -import { StyleSheet, StatusBar, Alert, Platform, Dimensions } from 'react-native'; - -import Server from "@SFJS/httpManager" -import CSSParser from "@Style/Util/CSSParser"; +import { Platform } from 'react-native'; +import Server from '@SFJS/httpManager'; +import CSSParser from '@Style/Util/CSSParser'; export default class ThemeDownloader { - static instance = null; static get() { @@ -16,34 +14,38 @@ export default class ThemeDownloader { } async downloadTheme(theme) { - let errorBlock = (error) => { - if(!theme.getNotAvailOnMobile()) { + let errorBlock = error => { + if (!theme.getNotAvailOnMobile()) { theme.setNotAvailOnMobile(true); theme.setDirty(true); } - console.error("Theme download error", error); - } + console.error('Theme download error', error); + }; var url = theme.hosted_url || theme.url; - if(!url) { + if (!url) { errorBlock(null); return; } - if(Platform.OS === "android" && url.includes("localhost")) { - url = url.replace("localhost", "10.0.2.2"); + if (Platform.OS === 'android' && url.includes('localhost')) { + url = url.replace('localhost', '10.0.2.2'); } - return new Promise((resolve, reject) => { - Server.get().getAbsolute(url, {}, (response) => { - let variables = CSSParser.cssToObject(response); - resolve(variables); - }, (response) => { - resolve(null); - }) - }) - + return new Promise(resolve => { + Server.get().getAbsolute( + url, + {}, + response => { + let variables = CSSParser.cssToObject(response); + resolve(variables); + }, + () => { + resolve(null); + } + ); + }); } } diff --git a/src/style/icons.js b/src/style/icons.js index 90a198d2..ee77d9e4 100644 --- a/src/style/icons.js +++ b/src/style/icons.js @@ -14,4 +14,4 @@ export const ICON_FINGER_PRINT = 'finger-print'; export const ICON_SHARE = 'share'; export const ICON_TRASH = 'trash'; export const ICON_USER = 'contact'; -export const ICON_FORWARD = 'arrow-round-forward'; \ No newline at end of file +export const ICON_FORWARD = 'arrow-round-forward';