You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
implemented own navigator
This commit is contained in:
36
ReactNativeClient/lib/components/app-nav.js
Normal file
36
ReactNativeClient/lib/components/app-nav.js
Normal file
@ -0,0 +1,36 @@
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux'
|
||||
import { View } from 'react-native';
|
||||
import { _ } from 'lib/locale.js';
|
||||
|
||||
class AppNavComponent extends Component {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.screenCache_ = [];
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.props.route) throw new Error('Route must not be null');
|
||||
|
||||
let route = this.props.route;
|
||||
let Screen = this.props.screens[route.routeName].screen;
|
||||
|
||||
return (
|
||||
<View style={{flex:1}}>
|
||||
<Screen style={{backgroundColor: '#f00'}} navigation={{ state: route }} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const AppNav = connect(
|
||||
(state) => {
|
||||
return {
|
||||
route: state.route,
|
||||
};
|
||||
}
|
||||
)(AppNavComponent)
|
||||
|
||||
export { AppNav };
|
19
ReactNativeClient/lib/components/base-screen.js
Normal file
19
ReactNativeClient/lib/components/base-screen.js
Normal file
@ -0,0 +1,19 @@
|
||||
import React, { Component } from 'react';
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
const styles_ = StyleSheet.create({
|
||||
screen: {
|
||||
flex: 1,
|
||||
backgroundColor: "#E9E9E9",
|
||||
},
|
||||
});
|
||||
|
||||
class BaseScreenComponent extends React.Component {
|
||||
|
||||
styles() {
|
||||
return styles_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { BaseScreenComponent };
|
@ -6,8 +6,9 @@ import { Folder } from 'lib/models/folder.js'
|
||||
import { BaseModel } from 'lib/base-model.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
|
||||
class FolderScreenComponent extends React.Component {
|
||||
class FolderScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -57,7 +58,7 @@ class FolderScreenComponent extends React.Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader navState={this.props.navigation.state} />
|
||||
<TextInput value={this.state.folder.title} onChangeText={(text) => this.title_changeText(text)} />
|
||||
<Button title="Save folder" onPress={() => this.saveFolderButton_press()} />
|
||||
|
@ -6,8 +6,9 @@ import { FolderList } from 'lib/components/folder-list.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { ActionButton } from 'lib/components/action-button.js';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
|
||||
class FoldersScreenComponent extends React.Component {
|
||||
class FoldersScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -15,7 +16,7 @@ class FoldersScreenComponent extends React.Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader navState={this.props.navigation.state} />
|
||||
<FolderList noItemMessage={_('There is currently no notebook. Create one by clicking on the (+) button.')} style={{flex: 1}}/>
|
||||
<ActionButton addFolderNoteButtons={true}></ActionButton>
|
||||
|
@ -6,8 +6,9 @@ import { reg } from 'lib/registry.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { time } from 'lib/time-utils'
|
||||
import { Logger } from 'lib/logger.js';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
|
||||
class LogScreenComponent extends React.Component {
|
||||
class LogScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -54,7 +55,7 @@ class LogScreenComponent extends React.Component {
|
||||
|
||||
// `enableEmptySections` is to fix this warning: https://github.com/FaridSafi/react-native-gifted-listview/issues/39
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader navState={this.props.navigation.state} />
|
||||
<ListView
|
||||
dataSource={this.state.dataSource}
|
||||
|
@ -10,6 +10,7 @@ import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { Checkbox } from 'lib/components/checkbox.js'
|
||||
import { _ } from 'lib/locale.js';
|
||||
import marked from 'lib/marked.js';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
webView: {
|
||||
@ -17,7 +18,7 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
class NoteScreenComponent extends React.Component {
|
||||
class NoteScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -231,7 +232,7 @@ class NoteScreenComponent extends React.Component {
|
||||
const actionButtonComp = renderActionButton();
|
||||
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader navState={this.props.navigation.state} menuOptions={this.menuOptions()} title={title} />
|
||||
<View style={{ flexDirection: 'row' }}>
|
||||
{ isTodo && <Checkbox checked={!!Number(note.todo_completed)} /> }<TextInput style={{flex:1}} value={note.title} onChangeText={(text) => this.title_changeText(text)} />
|
||||
|
@ -11,8 +11,9 @@ import { ActionButton } from 'lib/components/action-button.js';
|
||||
import { dialogs } from 'lib/dialogs.js';
|
||||
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||
import DialogBox from 'react-native-dialogbox';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
|
||||
class NotesScreenComponent extends React.Component {
|
||||
class NotesScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -52,7 +53,7 @@ class NotesScreenComponent extends React.Component {
|
||||
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader title={title} navState={this.props.navigation.state} menuOptions={this.menuOptions()} />
|
||||
<NoteList noItemMessage={_('There are currently no notes. Create one by clicking on the (+) button.')} style={{flex: 1}}/>
|
||||
<ActionButton addFolderNoteButtons={true} parentFolderId={this.props.selectedFolderId}></ActionButton>
|
||||
|
@ -7,8 +7,9 @@ import { Setting } from 'lib/models/setting.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { reg } from 'lib/registry.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
|
||||
class OneDriveLoginScreenComponent extends React.Component {
|
||||
class OneDriveLoginScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -85,7 +86,7 @@ class OneDriveLoginScreenComponent extends React.Component {
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader navState={this.props.navigation.state} />
|
||||
<WebView
|
||||
source={source}
|
||||
|
@ -10,8 +10,9 @@ import { BaseItem } from 'lib/models/base-item.js';
|
||||
import { Folder } from 'lib/models/folder.js';
|
||||
import { ReportService } from 'lib/services/report.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
|
||||
class StatusScreenComponent extends React.Component {
|
||||
class StatusScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -65,7 +66,7 @@ class StatusScreenComponent extends React.Component {
|
||||
let body = renderBody(this.state.report);
|
||||
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen}>
|
||||
<ScreenHeader navState={this.props.navigation.state} />
|
||||
<View style={{flex: 1}}>
|
||||
{ body }
|
||||
|
@ -4,9 +4,10 @@ import { connect } from 'react-redux'
|
||||
import { Log } from 'lib/log.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { ActionButton } from 'lib/components/action-button.js';
|
||||
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
||||
import { _ } from 'lib/locale.js';
|
||||
|
||||
class WelcomeScreenComponent extends React.Component {
|
||||
class WelcomeScreenComponent extends BaseScreenComponent {
|
||||
|
||||
static navigationOptions(options) {
|
||||
return { header: null };
|
||||
@ -23,7 +24,7 @@ class WelcomeScreenComponent extends React.Component {
|
||||
let message = this.props.folders.length ? _('Click on the (+) button to create a new note or notebook. Click on the side menu to access your existing notebooks.') : _('You currently have no notebook. Create one by clicking on (+) button.');
|
||||
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<View style={this.styles().screen} >
|
||||
<ScreenHeader navState={this.props.navigation.state}/>
|
||||
<Text>{message}</Text>
|
||||
<ActionButton addFolderNoteButtons={true}/>
|
||||
|
@ -16,8 +16,6 @@ const {
|
||||
} = require('react-native');
|
||||
const { Component } = React;
|
||||
|
||||
const window = Dimensions.get('window');
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
menu: {
|
||||
flex: 1,
|
||||
|
7
ReactNativeClient/lib/components/style.js
Normal file
7
ReactNativeClient/lib/components/style.js
Normal file
@ -0,0 +1,7 @@
|
||||
const styles = StyleSheet.create({
|
||||
webView: {
|
||||
fontSize: 10,
|
||||
},
|
||||
});
|
||||
|
||||
export { styles }
|
Reference in New Issue
Block a user