Skip to content

Commit

Permalink
chore: changed themes[theme] to colors
Browse files Browse the repository at this point in the history
  • Loading branch information
OtavioStasiak committed Nov 14, 2024
1 parent f16b2ca commit 7b8632b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 39 deletions.
7 changes: 2 additions & 5 deletions app/containers/TextInput/FormTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import sharedStyles from '../../views/Styles';
import ActivityIndicator from '../ActivityIndicator';
import { CustomIcon, TIconsName } from '../CustomIcon';
import { TextInput } from './TextInput';
import { themes } from '../../lib/constants';

const styles = StyleSheet.create({
error: {
Expand Down Expand Up @@ -94,7 +93,7 @@ export const FormTextInput = ({
accessibilityLabel,
...inputProps
}: IRCTextInputProps): React.ReactElement => {
const { colors, theme } = useTheme();
const { colors } = useTheme();
const [showPassword, setShowPassword] = useState(false);
const showClearInput = onClearInput && value && value.length > 0;
const Input = bottomSheet ? BottomSheetTextInput : TextInput;
Expand All @@ -105,9 +104,7 @@ export const FormTextInput = ({
accessibilityLabel={`${label} ${required ? i18n.t('Required') : ''}`}
style={[styles.label, { color: colors.fontTitlesLabels }, error?.error && { color: colors.fontDanger }]}>
{label}{' '}
{required && (
<Text style={[styles.required, { color: themes[theme].fontSecondaryInfo }]}>{`(${i18n.t('Required')})`}</Text>
)}
{required && <Text style={[styles.required, { color: colors.fontSecondaryInfo }]}>{`(${i18n.t('Required')})`}</Text>}
</Text>
) : null}

Expand Down
47 changes: 24 additions & 23 deletions app/views/NewServerView/ServerInput/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';

import { themes } from '../../../lib/constants';
import { useTheme } from '../../../theme';
import { CustomIcon } from '../../../containers/CustomIcon';
import { TServerHistoryModel } from '../../../definitions/IServerHistory';
import sharedStyles from '../../Styles';
import Touch from '../../../containers/Touch';
import { TServerHistoryModel } from '../../../definitions/IServerHistory';
import { TSupportedThemes } from '../../../theme';

const styles = StyleSheet.create({
container: {
Expand All @@ -29,30 +28,32 @@ const styles = StyleSheet.create({

interface IItem {
item: TServerHistoryModel;
theme: TSupportedThemes;
onPress(url: string): void;
onDelete(item: TServerHistoryModel): void;
}

const Item = ({ item, theme, onPress, onDelete }: IItem): JSX.Element => (
<Touch
style={styles.container}
onPress={() => onPress(item.url)}
testID={`server-history-${item.url}`}
accessible
accessibilityLabel={`${item.url} ${item.username}`}>
<View style={styles.content} accessible={false} accessibilityElementsHidden>
<Text numberOfLines={1} style={[styles.server, { color: themes[theme].fontDefault }]}>
{item.url}
</Text>
<Text numberOfLines={1} style={{ color: themes[theme].fontSecondaryInfo }}>
{item.username}
</Text>
</View>
<Touch onPress={() => onDelete(item)} testID={`server-history-delete-${item.url}`}>
<CustomIcon name='delete' size={24} color={themes[theme].fontSecondaryInfo} />
const Item = ({ item, onPress, onDelete }: IItem): JSX.Element => {
const { colors } = useTheme();
return (
<Touch
style={styles.container}
onPress={() => onPress(item.url)}
testID={`server-history-${item.url}`}
accessible
accessibilityLabel={`${item.url} ${item.username}`}>
<View style={styles.content} accessible={false} accessibilityElementsHidden>
<Text numberOfLines={1} style={[styles.server, { color: colors.fontDefault }]}>
{item.url}
</Text>
<Text numberOfLines={1} style={{ color: colors.fontSecondaryInfo }}>
{item.username}
</Text>
</View>
<Touch onPress={() => onDelete(item)} testID={`server-history-delete-${item.url}`}>
<CustomIcon name='delete' size={24} color={colors.fontSecondaryInfo} />
</Touch>
</Touch>
</Touch>
);
);
};

export default Item;
15 changes: 5 additions & 10 deletions app/views/NewServerView/ServerInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { useState } from 'react';
import { FlatList, StyleSheet, TextInputProps, View } from 'react-native';

import { useTheme } from '../../../theme';
import { FormTextInput } from '../../../containers/TextInput';
import { TServerHistoryModel } from '../../../definitions';
import * as List from '../../../containers/List';
import { themes } from '../../../lib/constants';
import I18n from '../../../i18n';
import { TServerHistoryModel } from '../../../definitions';
import Item from './Item';
import { TSupportedThemes } from '../../../theme';

const styles = StyleSheet.create({
container: {
Expand All @@ -31,7 +30,6 @@ const styles = StyleSheet.create({

interface IServerInput extends TextInputProps {
text: string;
theme: TSupportedThemes;
serversHistory: any[];
onSubmit(): void;
onDelete(item: TServerHistoryModel): void;
Expand All @@ -40,14 +38,14 @@ interface IServerInput extends TextInputProps {

const ServerInput = ({
text,
theme,
serversHistory,
onChangeText,
onSubmit,
onDelete,
onPressServerHistory
}: IServerInput): JSX.Element => {
const [focused, setFocused] = useState(false);
const { colors } = useTheme();
return (
<View style={styles.container}>
<FormTextInput
Expand All @@ -67,13 +65,10 @@ const ServerInput = ({
onBlur={() => setFocused(false)}
/>
{focused && serversHistory?.length ? (
<View
style={[styles.serverHistory, { backgroundColor: themes[theme].surfaceRoom, borderColor: themes[theme].strokeLight }]}>
<View style={[styles.serverHistory, { backgroundColor: colors.surfaceRoom, borderColor: colors.strokeLight }]}>
<FlatList
data={serversHistory}
renderItem={({ item }) => (
<Item item={item} theme={theme} onPress={() => onPressServerHistory(item)} onDelete={onDelete} />
)}
renderItem={({ item }) => <Item item={item} onPress={() => onPressServerHistory(item)} onDelete={onDelete} />}
ItemSeparatorComponent={List.Separator}
keyExtractor={item => item.id}
/>
Expand Down
1 change: 0 additions & 1 deletion app/views/NewServerView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ class NewServerView extends React.Component<INewServerViewProps, INewServerViewS
</Text>
<ServerInput
text={text}
theme={theme}
serversHistory={serversHistory}
onChangeText={this.onChangeText}
onSubmit={this.submit}
Expand Down

0 comments on commit 7b8632b

Please sign in to comment.