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
feat: add widget on ios
ammarahm-ed011a0f16cce1
diff --git a/apps/mobile/QuickNoteIOS.js b/apps/mobile/QuickNoteIOS.jsindex 374193ca3..0ba071955 100644--- a/apps/mobile/QuickNoteIOS.js+++ b/apps/mobile/QuickNoteIOS.js@@ -1,18 +1,22 @@-import React, { Component, createRef } from 'react';+import React, {Component, createRef} from 'react';import {ActivityIndicator,Appearance,- KeyboardAvoidingView, Platform, SafeAreaView, Text,+ KeyboardAvoidingView,+ Platform,+ SafeAreaView,+ Text,TouchableOpacity,View} from 'react-native';-import { TextInput } from 'react-native-gesture-handler';+import {TextInput} from 'react-native-gesture-handler';import SplashScreen from 'react-native-splash-screen';import ShareExtension from 'rn-extensions-share';-import { COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from './src/utils/Colors';-import { db } from './src/utils/database';+import NotesnookShare from './share';+import {COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT} from './src/utils/Colors';+import {db} from './src/utils/database';import Storage from './src/utils/storage';-import { sleep } from './src/utils/TimeUtils';+import {sleep} from './src/utils/TimeUtils';let validator;let linkPreview;@@ -29,7 +33,7 @@ export default class QuickNoteIOS extends Component {Appearance.getColorScheme() === 'dark'? COLOR_SCHEME_DARK: COLOR_SCHEME_LIGHT,- height: 0,+ height: 0};this.initialText = '';this.textInputRef = createRef();@@ -38,20 +42,20 @@ export default class QuickNoteIOS extends Component {componentDidMount() {SplashScreen.hide();- sleep(300).then(r => {- this.textInputRef.current?.focus()- })+ sleep(300).then(r => {+ this.textInputRef.current?.focus();+ });}close = () => {- ShareExtension.openURL('ShareMedia://MainApp');+ ShareExtension.openURL('ShareMedia://MainApp');};onPress = async () => {this.titleInputRef.current?.blur();this.textInputRef.current?.blur();this.setState({- loading: true,+ loading: true});let tag = `<p>${this.state.text}</p>`;@@ -61,9 +65,9 @@ export default class QuickNoteIOS extends Component {title: this.state.title,content: {type: 'tiny',- data: tag,+ data: tag},- id: null,+ id: null});};if (db && db.notes) {@@ -80,7 +84,7 @@ export default class QuickNoteIOS extends Component {saveBtn = () => (<Viewstyle={{- paddingHorizontal: 12,+ paddingHorizontal: 12}}><TouchableOpacityonPress={this.onPress}@@ -92,7 +96,7 @@ export default class QuickNoteIOS extends Component {borderRadius: 5,justifyContent: 'center',alignItems: 'center',- flexDirection: 'row',+ flexDirection: 'row'}}>{this.state.loading && (<ActivityIndicator color={this.state.colors.light} />@@ -103,7 +107,7 @@ export default class QuickNoteIOS extends Component {fontSize: 18,fontWeight: 'bold',color: this.state.colors.light,- marginLeft: this.state.loading ? 10 : 0,+ marginLeft: this.state.loading ? 10 : 0}}>Save Note</Text>@@ -118,101 +122,9 @@ export default class QuickNoteIOS extends Component {width: '100%',height: '100%',justifyContent: 'flex-start',- backgroundColor: this.state.colors.bg,+ backgroundColor: this.state.colors.nav}}>--- <KeyboardAvoidingView- enabled={Platform.OS === 'ios'}- style={{- paddingVertical: 25,- backgroundColor: this.state.colors.bg,- borderTopRightRadius: 10,- borderTopLeftRadius: 10,- }}- behavior="padding">- <View- style={{- maxHeight: '100%',- }}>- <View- style={{- flexDirection: 'row',- alignItems: 'center',- borderBottomWidth: 1,- borderBottomColor: this.state.colors.nav,- paddingHorizontal: 12,- justifyContent: 'space-between',- }}>- <TextInput- ref={this.titleInputRef}- style={{- fontSize: 25,- fontWeight: 'bold',- color: this.state.colors.pri,- flexGrow: 1,- maxWidth: '85%',- }}- placeholderTextColor={this.state.colors.icon}- value={this.state.title}- onChangeText={(v) => this.setState({title: v})}- onSubmitEditing={() => {- this.textInputRef.current?.focus();- }}- blurOnSubmit={false}- placeholder="Note title"- />-- <TouchableOpacity- onPress={this.close}- activeOpacity={0.8}- style={{- width: 60,- height: 40,- borderRadius: 5,- justifyContent: 'center',- alignItems: 'center',- flexDirection: 'row',- }}>- <Text- style={{- fontSize: 16,- fontWeight: 'bold',- color: this.state.colors.accent,- marginLeft: this.state.loading ? 10 : 0,- }}>- Cancel- </Text>- </TouchableOpacity>- </View>-- <TextInput- ref={this.textInputRef}- style={{- fontSize: 15,- color: this.state.colors.pri,- marginBottom: 10,- width: '100%',- maxHeight: '70%',- paddingVertical: 10,- paddingHorizontal: 12,- minHeight: 150,- }}- placeholderTextColor={this.state.colors.icon}- onChangeText={(v) => this.setState({text: v})}- multiline={true}- value={this.state.text}- blurOnSubmit={false}- placeholder="Type your note here"- />- {this.saveBtn()}- <View- style={{- height: 25,- }}- />- </View>- </KeyboardAvoidingView>+ <NotesnookShare quicknote={true} /></SafeAreaView>);}diff --git a/apps/mobile/ios/Make Note/Info.plist b/apps/mobile/ios/Make Note/Info.plistindex df964a2cb..79422902d 100644--- a/apps/mobile/ios/Make Note/Info.plist+++ b/apps/mobile/ios/Make Note/Info.plist@@ -44,6 +44,12 @@<key>NSExtensionPointIdentifier</key><string>com.apple.share-services</string></dict>+ <key>UIAppFonts</key>+ <array>+ <string>OpenSans-SemiBold.ttf</string>+ <string>OpenSans-Regular.ttf</string>+ <string>MaterialCommunityIcons.ttf</string>+ </array><key>UISupportedInterfaceOrientations</key><array><string>UIInterfaceOrientationPortrait</string>diff --git a/apps/mobile/ios/NotesWidget/NotesWidget.swift b/apps/mobile/ios/NotesWidget/NotesWidget.swiftindex efb784624..e3445a513 100644--- a/apps/mobile/ios/NotesWidget/NotesWidget.swift+++ b/apps/mobile/ios/NotesWidget/NotesWidget.swift@@ -9,67 +9,69 @@ import WidgetKitimport SwiftUIstruct Provider: TimelineProvider {- func placeholder(in context: Context) -> SimpleEntry {- SimpleEntry(date: Date())- }-- func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {- let entry = SimpleEntry(date: Date())- completion(entry)- }-- func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {- var entries: [SimpleEntry] = []-- // Generate a timeline consisting of five entries an hour apart, starting from the current date.- let currentDate = Date()- for hourOffset in 0 ..< 5 {- let entryDate = Calendar.current.date(byAdding: .day, value: hourOffset, to: currentDate)!- let entry = SimpleEntry(date: entryDate)- entries.append(entry)- }-- let timeline = Timeline(entries: entries, policy: .atEnd)- completion(timeline)+ func placeholder(in context: Context) -> SimpleEntry {+ SimpleEntry(date: Date())+ }++ func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {+ let entry = SimpleEntry(date: Date())+ completion(entry)+ }++ func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {+ var entries: [SimpleEntry] = []++ // Generate a timeline consisting of five entries an hour apart, starting from the current date.+ let currentDate = Date()+ for hourOffset in 0 ..< 5 {+ let entryDate = Calendar.current.date(byAdding: .day, value: hourOffset, to: currentDate)!+ let entry = SimpleEntry(date: entryDate)+ entries.append(entry)}++ let timeline = Timeline(entries: entries, policy: .atEnd)+ completion(timeline)+ }}struct SimpleEntry: TimelineEntry {- let date: Date+ let date: Date}struct NotesWidgetEntryView : View {- var entry: Provider.Entry-- var body: some View {- ZStack {-+ var entry: Provider.Entry++++ var body: some View {+ ZStack {VStack {- Image(systemName: "plus").font(.system(size: 30))- Text("Add a Note").font(.system(size: 20))- }.padding()+ Image(systemName: "plus").font(.system(size: 50)).offset(x: 0, y: 5)+ Text("Add a quick note").font(.system(size: 14)).offset(x: 0, y: 30)+ }- }.widgetURL(URL(string: "ShareMedia://QuickNoteWidget"))- }+ }.widgetURL(URL(string: "ShareMedia://QuickNoteWidget"))+ }+}@mainstruct NotesWidget: Widget {- let kind: String = "NotesWidget"+ let kind: String = "NotesWidget"- var body: some WidgetConfiguration {- StaticConfiguration(kind: kind, provider: Provider()) { entry in- NotesWidgetEntryView(entry: entry)- }- .configurationDisplayName("Quick Note")- .description("A widget to add notes quickly.")+ var body: some WidgetConfiguration {+ StaticConfiguration(kind: kind, provider: Provider()) { entry in+ NotesWidgetEntryView(entry: entry)}+ .configurationDisplayName("Quick Note")+ .description("A widget to add notes quickly.")+ }}struct NotesWidget_Previews: PreviewProvider {- static var previews: some View {- NotesWidgetEntryView(entry: SimpleEntry(date: Date()))- .previewContext(WidgetPreviewContext(family: .systemSmall))- }+ static var previews: some View {+ NotesWidgetEntryView(entry: SimpleEntry(date: Date()))+ .previewContext(WidgetPreviewContext(family: .systemSmall))+ }}diff --git a/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj b/apps/mobile/ios/Notesnook.xcodeproj/project.pbxprojindex e4492f350..b8057efe6 100644--- a/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj+++ b/apps/mobile/ios/Notesnook.xcodeproj/project.pbxproj@@ -21,6 +21,7 @@6510627627042895009661C3 /* OpenSans-SemiBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552012E27019F6E00A43C51 /* OpenSans-SemiBold.ttf */; };6510627727042896009661C3 /* OpenSans-SemiBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552012E27019F6E00A43C51 /* OpenSans-SemiBold.ttf */; };6515C42F2580AA3000E83E39 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6515C42E2580AA2F00E83E39 /* StoreKit.framework */; };+ 654B3C47271417CE00B5081A /* Web.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 655FD779253AD31C001D807D /* Web.bundle */; };655FD77A253AD31C001D807D /* Web.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 655FD779253AD31C001D807D /* Web.bundle */; };656BFBC22696AC320063D1DD /* Plain.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 656BFBC12696AC320063D1DD /* Plain.bundle */; };659BE46725E11A5100E05671 /* notesnook-text.png in Resources */ = {isa = PBXBuildFile; fileRef = 659BE46625E11A5100E05671 /* notesnook-text.png */; };@@ -113,7 +114,7 @@6529D2B0257B4A2900B49BC3 /* NotesnookDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = NotesnookDebug.entitlements; path = Notesnook/NotesnookDebug.entitlements; sourceTree = "<group>"; };6552012E27019F6E00A43C51 /* OpenSans-SemiBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "OpenSans-SemiBold.ttf"; path = "../android/app/src/main/assets/fonts/OpenSans-SemiBold.ttf"; sourceTree = "<group>"; };6552012F27019F7700A43C51 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "OpenSans-Regular.ttf"; path = "../android/app/src/main/assets/fonts/OpenSans-Regular.ttf"; sourceTree = "<group>"; };- 655FD779253AD31C001D807D /* Web.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Web.bundle; path = ../html/Web.bundle; sourceTree = "<group>"; };+ 655FD779253AD31C001D807D /* Web.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Web.bundle; sourceTree = "<group>"; };656BFBC12696AC320063D1DD /* Plain.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Plain.bundle; path = ../../html/Plain.bundle; sourceTree = "<group>"; };659BE46625E11A5100E05671 /* notesnook-text.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "notesnook-text.png"; path = "Notesnook/Images.xcassets/notesnook-text.png"; sourceTree = "<group>"; };65A7F34F255689AD00699170 /* Notesnook.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Notesnook.entitlements; path = Notesnook/Notesnook.entitlements; sourceTree = "<group>"; };@@ -222,10 +223,10 @@13B07FAE1A68108700A75B9A /* Notesnook */ = {isa = PBXGroup;children = (+ 655FD779253AD31C001D807D /* Web.bundle */,659BE46625E11A5100E05671 /* notesnook-text.png */,6529D2B0257B4A2900B49BC3 /* NotesnookDebug.entitlements */,65A7F34F255689AD00699170 /* Notesnook.entitlements */,- 655FD779253AD31C001D807D /* Web.bundle */,008F07F21AC5B25A0029DE68 /* main.jsbundle */,13B07FAF1A68108700A75B9A /* AppDelegate.h */,13B07FB01A68108700A75B9A /* AppDelegate.m */,@@ -574,6 +575,7 @@files = (6510627727042896009661C3 /* OpenSans-SemiBold.ttf in Resources */,656BFBC22696AC320063D1DD /* Plain.bundle in Resources */,+ 654B3C47271417CE00B5081A /* Web.bundle in Resources */,6510627527042893009661C3 /* OpenSans-Regular.ttf in Resources */,65B5014725A672B200E2D264 /* MainInterface.storyboard in Resources */,);@@ -1130,7 +1132,7 @@baseConfigurationReference = 19E7EB248446C3FE09F6E622 /* Pods-Notesnook.debug.xcconfig */;buildSettings = {ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;- APPLICATION_EXTENSION_API_ONLY = YES;+ APPLICATION_EXTENSION_API_ONLY = NO;ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;CLANG_ENABLE_MODULES = YES;CODE_SIGN_ENTITLEMENTS = Notesnook/NotesnookDebug.entitlements;@@ -1231,7 +1233,7 @@baseConfigurationReference = 77124A1C1FB538ED63FDEF82 /* Pods-Notesnook.release.xcconfig */;buildSettings = {ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;- APPLICATION_EXTENSION_API_ONLY = YES;+ APPLICATION_EXTENSION_API_ONLY = NO;ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;CLANG_ENABLE_MODULES = YES;CODE_SIGN_ENTITLEMENTS = Notesnook/Notesnook.entitlements;@@ -1451,6 +1453,7 @@65AA858525E6DDEF00772A01 /* Debug */ = {isa = XCBuildConfiguration;buildSettings = {+ APPLICATION_EXTENSION_API_ONLY = NO;ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;CLANG_ANALYZER_NONNULL = YES;@@ -1488,6 +1491,7 @@65AA858625E6DDEF00772A01 /* Release */ = {isa = XCBuildConfiguration;buildSettings = {+ APPLICATION_EXTENSION_API_ONLY = NO;ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;CLANG_ANALYZER_NONNULL = YES;diff --git a/apps/mobile/share/index.js b/apps/mobile/share/index.jsindex c1832b6ab..791c7fc75 100644--- a/apps/mobile/share/index.js+++ b/apps/mobile/share/index.js@@ -1,18 +1,25 @@import Clipboard from '@react-native-clipboard/clipboard';import absolutify from 'absolutify';-import { getLinkPreview } from 'link-preview-js';-import React, { useEffect, useRef, useState } from 'react';+import {getLinkPreview} from 'link-preview-js';+import React, {useEffect, useRef, useState} from 'react';import {ActivityIndicator,- Alert, Keyboard,+ Alert,+ Keyboard,KeyboardAvoidingView,Platform,SafeAreaView,- Text, TouchableOpacity,+ Text,+ TouchableOpacity,useWindowDimensions,View} from 'react-native';-import Animated, { Easing, timing, useValue } from 'react-native-reanimated';+import Animated, {+ color,+ Easing,+ timing,+ useValue+} from 'react-native-reanimated';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import WebView from 'react-native-webview';import ShareExtension from 'rn-extensions-share';@@ -22,12 +29,12 @@ import {eSubscribeEvent,eUnSubscribeEvent} from '../src/services/EventManager';-import { getElevation } from '../src/utils';-import { db } from '../src/utils/database';+import {getElevation} from '../src/utils';+import {db} from '../src/utils/database';import Storage from '../src/utils/storage';-import { sleep } from '../src/utils/TimeUtils';-import { Search } from './search';-import { useShareStore } from './store';+import {sleep} from '../src/utils/TimeUtils';+import {Search} from './search';+import {useShareStore} from './store';const AnimatedKAV = Animated.createAnimatedComponent(KeyboardAvoidingView);const AnimatedSAV = Animated.createAnimatedComponent(SafeAreaView);@@ -108,7 +115,7 @@ const modes = {}};-const NotesnookShare = () => {+const NotesnookShare = ({quicknote = false}) => {const colors = useShareStore(state => state.colors);const appendNote = useShareStore(state => state.appendNote);const [note, setNote] = useState({...defaultNote});@@ -233,7 +240,11 @@ const NotesnookShare = () => {await sleep(300);setNote({...defaultNote});setLoadingIntent(true);- ShareExtension.close();+ if (quicknote) {+ ShareExtension.openURL('ShareMedia://MainApp');+ } else {+ ShareExtension.close();+ }};const onLoad = () => {@@ -368,32 +379,61 @@ const NotesnookShare = () => {style={{width: width > 500 ? 500 : width,height: height,- justifyContent: 'flex-end',+ justifyContent: quicknote ? 'center' : 'flex-end',opacity: Platform.OS !== 'ios' ? opacity : 1}}>- <TouchableOpacity- activeOpacity={1}- onPress={() => {- if (showSearch) {- setShowSearch(false);- animate(1, 0);- } else {- close();- }- }}- style={{- width: '100%',- height: '100%',- position: 'absolute'- }}>- <View+ {quicknote ? (+ <Button+ type="action"+ icon="close"+ color={colors.transGray}+ iconColor={colors.pri}+ onPress={() => {+ if (showSearch) {+ console.log('hide search');+ setShowSearch(false);+ animate(1, 0);+ } else {+ close();+ }+ }}style={{- width: '100%',- height: '100%',- backgroundColor: 'rgba(0,0,0,0)'+ position: 'absolute',+ right: 12,+ top: 12,+ width: 50,+ height: 50}}+ iconSize={25}/>- </TouchableOpacity>+ ) : (+ <TouchableOpacity+ activeOpacity={1}+ onPress={() => {+ if (showSearch) {+ console.log('hide search');+ setShowSearch(false);+ animate(1, 0);+ } else {+ close();+ }+ }}+ style={{+ width: '100%',+ height: '100%',+ position: 'absolute'+ }}>+ <View+ style={{+ width: '100%',+ height: '100%',+ backgroundColor: 'white',+ opacity: 0.01+ }}+ />+ <View />+ </TouchableOpacity>+ )}{showSearch && (<Search@@ -447,7 +487,8 @@ const NotesnookShare = () => {textColor={!appendNote ? colors.light : colors.icon}type="rounded"style={{- paddingHorizontal: 12+ paddingHorizontal: 12,+ ...getElevation(1)}}/>@@ -460,13 +501,14 @@ const NotesnookShare = () => {icon="text-short"iconSize={18}iconColor={appendNote ? colors.light : colors.icon}- title={`Append to ${- appendNote ? appendNote.title.slice(0, 15) : 'note'+ title={`${+ appendNote ? appendNote.title.slice(0, 15) : 'Append to note'}`}textColor={appendNote ? colors.light : colors.icon}type="rounded"style={{- paddingHorizontal: 12+ paddingHorizontal: 12,+ ...getElevation(1)}}/></View>@@ -505,7 +547,8 @@ const NotesnookShare = () => {style={{width: '100%',height: height * 0.25,- paddingBottom: 15+ paddingBottom: 15,+ borderRadius: 10}}><WebViewonLoad={onLoad}@@ -513,7 +556,7 @@ const NotesnookShare = () => {style={{width: '100%',height: '100%',- backgroundColor: 'transparent'+ borderRadius: 10}}cacheMode="LOAD_DEFAULT"domStorageEnabled={true}@@ -602,7 +645,7 @@ const NotesnookShare = () => {</View><Viewstyle={{- height: 40+ height: Platform.OS === 'ios' ? 60 : 40}}/></View>@@ -619,7 +662,7 @@ const Button = ({style,textStyle,icon,- iconSize = 1,+ iconSize = 22,type = 'button',iconColor = 'gray',textColor = 'white'diff --git a/apps/mobile/share/search.js b/apps/mobile/share/search.jsindex 18e0c54aa..60699a83c 100644--- a/apps/mobile/share/search.js+++ b/apps/mobile/share/search.js@@ -2,6 +2,7 @@ import React, {useEffect, useRef, useState} from 'react';import {ActivityIndicator,FlatList,+ Platform,Text,TextInput,TouchableOpacity,@@ -87,7 +88,7 @@ export const Search = ({close, getKeyboardHeight}) => {<Viewstyle={{position: 'absolute',- top: 20,+ top:Platform.OS === "android" ? 20 : 0,backgroundColor: colors.bg,borderRadius: 10,width: '95%',@@ -103,7 +104,8 @@ export const Search = ({close, getKeyboardHeight}) => {justifyContent: 'space-between',alignItems: 'center',paddingHorizontal: 12,- marginBottom: 10+ marginBottom: 10,+ height:50}}><TextInputref={inputRef}