Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddNotes: improved layout and colors #1520

Merged
merged 1 commit into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Button as ElementsButton } from 'react-native-elements';
import { themeColor } from './../utils/ThemeUtils';
import { StyleProp, ViewStyle } from 'react-native';

interface ButtonProps {
title: string;
Expand All @@ -15,7 +16,7 @@ interface ButtonProps {
iconOnly?: boolean;
adaptiveWidth?: boolean;
containerStyle?: any;
buttonStyle?: any;
buttonStyle?: StyleProp<ViewStyle>;
noUppercase?: boolean;
disabled?: boolean;
}
Expand Down
3 changes: 2 additions & 1 deletion components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import { Header, Icon } from 'react-native-elements';
import { themeColor } from '../utils/ThemeUtils';
import { StyleProp, ViewStyle } from 'react-native';

interface HeaderProps {
leftComponent?: 'Back' | 'Close' | JSX.Element;
centerComponent?: JSX.Element;
rightComponent?: JSX.Element;
containerStyle?: any;
containerStyle?: StyleProp<ViewStyle>;
placement?: 'left' | 'center' | 'right' | undefined;
navigation?: any;
onBack?: () => void;
Expand Down
15 changes: 12 additions & 3 deletions components/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import * as React from 'react';
import {
StyleProp,
StyleSheet,
Text,
TextInput as TextInputRN,
TextStyle,
TouchableOpacity,
View
View,
ViewStyle
} from 'react-native';
import { themeColor } from './../utils/ThemeUtils';

Expand All @@ -13,7 +16,8 @@ interface TextInputProps {
value?: string;
onChangeText?: any;
numberOfLines?: number;
style?: any;
style?: StyleProp<ViewStyle>;
textInputStyle?: StyleProp<TextStyle>;
placeholderTextColor?: string;
locked?: boolean;
keyboardType?: string;
Expand All @@ -36,6 +40,7 @@ export default function TextInput(props: TextInputProps) {
onChangeText,
numberOfLines,
style,
textInputStyle,
placeholderTextColor,
locked,
keyboardType,
Expand Down Expand Up @@ -96,7 +101,11 @@ export default function TextInput(props: TextInputProps) {
value={value}
onChangeText={onChangeText}
numberOfLines={numberOfLines || 1}
style={{ ...styles.input, color: themeColor('text') }}
style={{
...textInputStyle,
...styles.input,
color: themeColor('text')
}}
placeholderTextColor={
placeholderTextColor || themeColor('secondaryText')
}
Expand Down
97 changes: 65 additions & 32 deletions views/AddNotes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Keyboard, View, TextInput } from 'react-native';
import { Keyboard, View } from 'react-native';
import EncryptedStorage from 'react-native-encrypted-storage';
import { inject, observer } from 'mobx-react';

Expand All @@ -11,6 +11,7 @@ import { localeString } from '../utils/LocaleUtils';
import { themeColor } from '../utils/ThemeUtils';

import NotesStore from '../stores/NotesStore';
import TextInput from '../components/TextInput';

interface AddNotesProps {
navigation: any;
Expand Down Expand Up @@ -69,21 +70,30 @@ export default class AddNotes extends React.Component<
const { notes } = this.state;
return (
<Screen>
<Header
leftComponent="Back"
centerComponent={{
text: isNoteStored
? localeString('views.SendingLightning.UpdateNote')
: localeString('views.SendingLightning.AddANote'),
style: {
color: themeColor('text'),
fontFamily: 'Lato-Regular',
fontSize: 20
}
<View
style={{
flexDirection: 'column',
height: '100%'
}}
navigation={navigation}
/>
<View style={{ padding: 20 }}>
>
<Header
leftComponent="Back"
centerComponent={{
text: isNoteStored
? localeString(
'views.SendingLightning.UpdateNote'
)
: localeString(
'views.SendingLightning.AddANote'
),
style: {
color: themeColor('text'),
fontFamily: 'Lato-Regular',
fontSize: 20
}
}}
navigation={navigation}
/>
<TextInput
onChangeText={(text: string) => {
this.setState({ notes: text });
Expand All @@ -96,28 +106,51 @@ export default class AddNotes extends React.Component<
}}
multiline
numberOfLines={0}
style={{ fontSize: 20, color: themeColor('text') }}
style={{
padding: 20,
flexGrow: 1,
flexShrink: 1
}}
textInputStyle={{
height: '100%',
textAlignVertical: 'top',
marginTop: -13
}}
value={notes}
placeholder={localeString('views.Payment.writeNote')}
onSubmitEditing={() => Keyboard.dismiss()}
/>
<View
style={{
marginHorizontal: 20,
marginBottom: 20,
marginTop: 10
}}
>
<Button
title={
isNoteStored
? localeString(
'views.SendingLightning.UpdateNote'
)
: localeString(
'views.SendingLightning.AddANote'
)
}
onPress={async () => {
const key: string =
'note-' +
(payment_hash || txid || RPreimage);
EncryptedStorage.setItem(key, notes);
await storeNoteKeys(key, notes);
navigation.goBack();
}}
buttonStyle={{
padding: 15
}}
/>
</View>
</View>
<Button
title={
isNoteStored
? localeString('views.SendingLightning.UpdateNote')
: localeString('views.SendingLightning.AddANote')
}
onPress={async () => {
const key: string =
'note-' + (payment_hash || txid || RPreimage);
await EncryptedStorage.setItem(key, notes);
await storeNoteKeys(key, notes);
navigation.goBack();
}}
containerStyle={{ position: 'absolute', bottom: 40 }}
buttonStyle={{ padding: 15 }}
/>
</Screen>
);
}
Expand Down