Skip to content

Commit 5ac72c3

Browse files
committed
3 more dependencies are removed. Library is more clear now
1 parent dc3ae73 commit 5ac72c3

13 files changed

Lines changed: 119 additions & 61 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ npm i react-native-login-screen
2828

2929
```js
3030
"react-native-spinkit": ">= 1.5.0",
31-
"react-native-vector-icons": ">= 6.6.0",
32-
"@freakycoder/react-native-helpers": "0.1.0",
33-
"react-native-dynamic-vector-icons": ">= 0.2.1",
3431
"react-native-material-textfield": "https://github.com/WrathChaos/react-native-material-textfield.git"
3532
```
3633

@@ -142,6 +139,7 @@ Pretty advanced and fully customizable example of login screen
142139
| disableSignupButton | boolean | false | disable the signup button if you do not want it |
143140
| usernameIconComponent | component | default | set any component instead of username icon component |
144141
| passwordIconComponent | component | default | set any component instead of password icon component |
142+
| settingsIconComponent | component | default | set any component instead of settings icon component |
145143
| usernameTextInputValue | value | default | set username's text input value |
146144
| passwordTextInputValue | value | default | set password's text input value |
147145
| usernamePlaceholder | string | Username | change the username text input's placeholder |
439 KB
Loading
2.6 MB
Loading

example/App.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ const App = () => {
4242
}}
4343
signupStyle={{
4444
color: "#fdfdfd",
45+
fontSize: 16,
4546
fontFamily: "Now-Bold",
4647
}}
47-
usernameOnChangeText={(username) => console.log("Username: ", username)}
48+
usernameOnChangeText={(username: string) =>
49+
console.log("Username: ", username)
50+
}
4851
onPressSettings={() => alert("Settings Button is pressed")}
49-
passwordOnChangeText={(password) => console.log("Password: ", password)}
52+
passwordOnChangeText={(password: string) =>
53+
console.log("Password: ", password)
54+
}
5055
onPressLogin={() => {
5156
setSpinnerVisibility(true);
5257
setTimeout(() => {

lib/LoginScreen.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ import Spinner from "react-native-spinkit";
1111
/**
1212
* ? Local Imports
1313
*/
14-
import Logo from "./components/Logo/Logo";
14+
import Logo, { ILogoProps } from "./components/Logo/Logo";
1515
import styles, { container } from "./LoginScreen.style";
16-
import BottomContainer from "./components/BottomContainer/BottomContainer";
16+
import BottomContainer, {
17+
IBottomContainerProps,
18+
} from "./components/BottomContainer/BottomContainer";
19+
import { ICardProps } from "./components/Card/Card";
1720

18-
export interface ILoginProps {
19-
source: any;
21+
export interface ILoginProps
22+
extends IBottomContainerProps,
23+
ILogoProps,
24+
ICardProps {
25+
source?: any;
2026
loginText?: string;
2127
spinnerStyle?: any;
2228
signupText: string;

lib/components/BottomContainer/BottomContainer.style.ts

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { ViewStyle, TextStyle, StyleSheet, Dimensions } from "react-native";
1+
import {
2+
ViewStyle,
3+
TextStyle,
4+
StyleSheet,
5+
Dimensions,
6+
ImageStyle,
7+
} from "react-native";
28
const { width, height } = Dimensions.get("window");
39

410
interface Style {
@@ -7,9 +13,18 @@ interface Style {
713
signupContainer: ViewStyle;
814
signupTextStyle: TextStyle;
915
signupButtonStyle: TextStyle;
16+
signupButtonRightArrowContainer: ViewStyle;
17+
signupButtonRightArrowImageStyle: ImageStyle;
18+
settingsIconContainer: ViewStyle;
19+
settingsIconImageStyle: ImageStyle;
20+
passwordIconImageStyle: ImageStyle;
21+
userIconImageStyle: ImageStyle;
1022
}
1123

12-
export const container = (backgroundColor: string, cardState: boolean) => {
24+
export const container = (
25+
backgroundColor: string = "rgba(255,255,255,0.45)",
26+
cardState: boolean = false,
27+
): ViewStyle => {
1328
return {
1429
backgroundColor,
1530
borderRadius: 24,
@@ -40,12 +55,41 @@ export default StyleSheet.create<Style>({
4055
fontWeight: "700",
4156
},
4257
signupButtonStyle: {
43-
padding: 12,
58+
padding: 10,
4459
minHeight: 30,
4560
borderRadius: 16,
4661
marginLeft: "auto",
62+
flexDirection: "row",
4763
alignItems: "center",
4864
justifyContent: "center",
4965
backgroundColor: "rgba(0,0,0,0.45)",
5066
},
67+
signupButtonRightArrowContainer: {
68+
marginLeft: 5,
69+
},
70+
signupButtonRightArrowImageStyle: {
71+
width: 15,
72+
height: 15,
73+
},
74+
settingsIconContainer: {
75+
shadowRadius: 3,
76+
shadowOpacity: 0.7,
77+
shadowColor: "#757575",
78+
shadowOffset: {
79+
width: 0,
80+
height: 3,
81+
},
82+
},
83+
settingsIconImageStyle: {
84+
width: 35,
85+
height: 35,
86+
},
87+
passwordIconImageStyle: {
88+
width: 30,
89+
height: 30,
90+
},
91+
userIconImageStyle: {
92+
width: 30,
93+
height: 30,
94+
},
5195
});

lib/components/BottomContainer/BottomContainer.tsx

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import * as React from "react";
2-
import { Text, View, TouchableOpacity } from "react-native";
3-
import Icon from "react-native-dynamic-vector-icons";
2+
import { Text, View, Image, TouchableOpacity } from "react-native";
43
/**
54
* ? Local Imports
65
*/
76
import Card from "../Card/Card";
87
import styles, { container } from "./BottomContainer.style";
98

10-
interface IBottomContainerProps {
9+
export interface IBottomContainerProps {
1110
signupStyle?: any;
1211
signupText?: string;
1312
emailTitle?: string;
1413
cardState?: boolean;
15-
IconComponent?: any;
1614
usernameTitle?: string;
1715
passwordTitle?: string;
1816
contentComponent?: any;
@@ -33,6 +31,7 @@ interface IBottomContainerProps {
3331
usernameTextInputValue?: string;
3432
passwordTextInputValue?: string;
3533
repasswordTextInputValue?: string;
34+
settingsIconComponent?: React.ReactNode;
3635
onSignUpPress?: () => void;
3736
onPressSettings?: () => void;
3837
emailOnChangeText?: (text: string) => void;
@@ -45,7 +44,6 @@ const BottomContainer = (props: IBottomContainerProps) => {
4544
const {
4645
cardState,
4746
onSignUpPress,
48-
IconComponent,
4947
backgroundColor,
5048
onPressSettings,
5149
disableSettings,
@@ -58,39 +56,59 @@ const BottomContainer = (props: IBottomContainerProps) => {
5856
passwordIconComponent,
5957
usernameTextInputValue,
6058
passwordTextInputValue,
59+
settingsIconComponent,
6160
signupText,
6261
signupStyle,
6362
disableSignupButton,
6463
loginButtonText,
65-
emailTitle,
6664
emailPlaceholder,
6765
emailOnChangeText,
6866
emailIconComponent,
6967
emailTextInputValue,
70-
repasswordTitle,
7168
repasswordTextInputValue,
7269
repasswordPlaceholder,
7370
repasswordOnChangeText,
7471
repasswordIconComponent,
7572
} = props;
7673

74+
const renderUserIcon = () => (
75+
<Image
76+
source={require("../../local-assets/user.png")}
77+
style={styles.userIconImageStyle}
78+
/>
79+
);
80+
81+
const renderPasswordIcon = () => (
82+
<Image
83+
source={require("../../local-assets/password.png")}
84+
style={styles.passwordIconImageStyle}
85+
/>
86+
);
87+
88+
const renderSettingsIcon = () => (
89+
<View style={styles.settingsIconContainer}>
90+
<Image
91+
source={require("../../local-assets/settings.png")}
92+
style={styles.settingsIconImageStyle}
93+
/>
94+
</View>
95+
);
96+
7797
const renderLoginCards = () => {
7898
return (
7999
<View>
80100
<Card
81101
value={usernameTextInputValue}
82102
placeholder={usernamePlaceholder}
83103
onChangeText={usernameOnChangeText}
84-
iconComponent={usernameIconComponent}
104+
iconComponent={usernameIconComponent || renderUserIcon()}
85105
{...props}
86106
/>
87107
<Card
88-
name="key"
89108
secureTextEntry
90-
type="FontAwesome"
91109
value={passwordTextInputValue}
92110
placeholder={passwordPlaceholder}
93-
iconComponent={passwordIconComponent}
111+
iconComponent={passwordIconComponent || renderPasswordIcon()}
94112
onChangeText={(text: string) =>
95113
passwordOnChangeText && passwordOnChangeText(text)
96114
}
@@ -107,27 +125,23 @@ const BottomContainer = (props: IBottomContainerProps) => {
107125
value={emailTextInputValue}
108126
placeholder={emailPlaceholder}
109127
onChangeText={emailOnChangeText}
110-
iconComponent={emailIconComponent}
128+
iconComponent={emailIconComponent || renderUserIcon()}
111129
{...props}
112130
/>
113131
<Card
114132
secureTextEntry
115133
value={passwordTextInputValue}
116134
placeholder={passwordPlaceholder}
117135
onChangeText={passwordOnChangeText}
118-
iconComponent={passwordIconComponent}
119-
name="key"
120-
type="FontAwesome"
136+
iconComponent={passwordIconComponent || renderPasswordIcon()}
121137
{...props}
122138
/>
123139
<Card
124140
secureTextEntry
125141
value={repasswordTextInputValue}
126142
placeholder={repasswordPlaceholder}
127143
onChangeText={repasswordOnChangeText}
128-
iconComponent={repasswordIconComponent}
129-
name="key"
130-
type="FontAwesome"
144+
iconComponent={repasswordIconComponent || renderPasswordIcon()}
131145
{...props}
132146
/>
133147
</View>
@@ -146,15 +160,9 @@ const BottomContainer = (props: IBottomContainerProps) => {
146160
{!disableSettings && (
147161
<TouchableOpacity
148162
onPress={onPressSettings}
149-
style={{ marginRight: "auto" }}
163+
style={{ marginRight: "auto", marginLeft: 12 }}
150164
>
151-
<IconComponent
152-
size={35}
153-
type="Ionicons"
154-
name="ios-settings"
155-
color="rgba(255,255,255, 0.9)"
156-
{...props}
157-
/>
165+
{settingsIconComponent || renderSettingsIcon()}
158166
</TouchableOpacity>
159167
)}
160168
{!disableSignupButton && (
@@ -165,6 +173,12 @@ const BottomContainer = (props: IBottomContainerProps) => {
165173
<Text style={signupStyle || styles.signupTextStyle}>
166174
{cardState ? signupText : loginButtonText}
167175
</Text>
176+
<View style={styles.signupButtonRightArrowContainer}>
177+
<Image
178+
source={require("../../local-assets/right-arrow.png")}
179+
style={styles.signupButtonRightArrowImageStyle}
180+
/>
181+
</View>
168182
</TouchableOpacity>
169183
)}
170184
</View>
@@ -173,7 +187,6 @@ const BottomContainer = (props: IBottomContainerProps) => {
173187
};
174188

175189
BottomContainer.defaultProps = {
176-
IconComponent: Icon,
177190
loginButtonText: "Already Have Account",
178191
disableSwitch: false,
179192
disableSettings: false,
@@ -184,7 +197,6 @@ BottomContainer.defaultProps = {
184197
usernamePlaceholder: "Username",
185198
passwordPlaceholder: "Password",
186199
repasswordPlaceholder: "Re-password",
187-
backgroundColor: "rgba(255,255,255,0.45)",
188200
};
189201

190202
export default BottomContainer;

lib/components/Card/Card.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
import * as React from "react";
22
import { View } from "react-native";
3-
import Icon from "react-native-dynamic-vector-icons";
43
import { TextField } from "react-native-material-textfield";
54
/**
65
* ? Local Imports
76
*/
87
import styles, { _textStyle, _textInputStyle } from "./Card.style";
98

109
export interface ICardProps {
10+
value?: string;
1111
iconComponent?: any;
1212
placeholder?: string;
13+
secureTextEntry?: boolean;
1314
onChangeText?: (text: string) => void;
1415
}
1516

1617
const Card = (props: ICardProps) => {
17-
const { placeholder, onChangeText, iconComponent } = props;
18+
const {
19+
value,
20+
placeholder,
21+
onChangeText,
22+
secureTextEntry,
23+
iconComponent,
24+
} = props;
1825
return (
1926
<View style={styles.container}>
2027
<View style={styles.containerGlue}>
21-
<View style={styles.iconContainer}>
22-
{iconComponent || (
23-
<Icon
24-
size={30}
25-
name="user-o"
26-
color="black"
27-
type="FontAwesome"
28-
{...props}
29-
/>
30-
)}
31-
</View>
28+
<View style={styles.iconContainer}>{iconComponent}</View>
3229
<View style={styles.textContainer}>
3330
<TextField
3431
{...props}
32+
value={value}
3533
label={placeholder}
3634
onChangeText={onChangeText}
35+
secureTextEntry={secureTextEntry}
3736
/>
3837
</View>
3938
</View>
@@ -42,7 +41,7 @@ const Card = (props: ICardProps) => {
4241
};
4342

4443
Card.defaultProps = {
45-
placeholder: "John Doe",
44+
placeholder: "Username",
4645
};
4746

4847
export default Card;

lib/local-assets/password.png

943 Bytes
Loading

lib/local-assets/right-arrow.png

456 Bytes
Loading

0 commit comments

Comments
 (0)