-
Notifications
You must be signed in to change notification settings - Fork 0
Todo list implementation #1
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
base: dev
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1 @@ | |||
| A react native application with todo implementation. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally add TODO now you have implemented. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅
shivamkrpandey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test it with iOS too.
tsconfig.json
Outdated
| // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ | ||
| // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/App.tsx
Outdated
| marginTop: 5, | ||
| marginBottom: 5 | ||
| }, | ||
| listItemCont: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you install spell-check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. spell-check didn't show an error for this. 😅
Fixed.
src/App.tsx
Outdated
|
|
||
| Keyboard.addListener( | ||
| isAndroid ? "keyboardDidHide" : "keyboardWillHide", | ||
| () => this.setState({ viewPadding: viewPadding }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can Use shorthand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| ); | ||
|
|
||
| const tasks = await this.getTasksFromStorage() | ||
| this.setState({tasks}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setState only once, line 36,41 and 45 can be combined as
this.setState({ viewPadding: someVarHoldingTheValue, tasks })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting different padding when the keyboard is visible and when it's hidden. So, this can not be combined.
| render(): JSX.Element { | ||
| return ( | ||
| <View style={[styles.container, { paddingBottom: this.state.viewPadding }]}> | ||
| <FlatList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list and text inputs can be broken down into shorter renders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would look weird. Since this view only renders FlatList and TextInput and there is no logic. I am just passing the props.
renderItem prop's implementation has been moved to a separate function. That should make it readable now.
| testID='flat-list' | ||
| style={styles.list} | ||
| data={this.state.tasks} | ||
| renderItem={(task: { index: number, item: { text: string, key: string, isCompleted: boolean } }) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderItem can move out as a separate function, it's for the ease of debugging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Title
Todo list implementation
Problem
Ramping up react native.
Solution / Approach
Creating a react native app to learn the basics.
Dependencies?
None
Test Procedures
Clone the repo and then run:
npm i
exp start (You may need to install expo)
Download expo app from play store and scan the QR code.
Test the basic Todo implementation
Additional comments / concerns
None