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

Make App Responsiveness #60

Merged
merged 85 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
a056263
add to PR template
Raidakarim May 30, 2023
6a6b434
add new .md
Raidakarim May 30, 2023
957ebd3
add md link
Raidakarim May 30, 2023
32a911b
undo
Raidakarim May 30, 2023
89310b1
Update ResponsivenessTesting.md
Raidakarim May 30, 2023
07b74a6
update md file
Raidakarim May 30, 2023
8702b67
Merge branch 'main' into raidak/responsiveness
Raidakarim May 31, 2023
afa504b
initial code for responsiveness
Raidakarim May 31, 2023
8f266b7
landscape views
Raidakarim Jun 1, 2023
3bfa767
landscape changes
Raidakarim Jun 1, 2023
d9c88e8
add arrow code
Raidakarim Jun 2, 2023
dec5fe6
rearrange buttons
Raidakarim Jun 2, 2023
1e07ea2
biteSelect
Raidakarim Jun 2, 2023
a28c684
Update ResponsivenessTesting.md
Raidakarim Jun 2, 2023
c2a0e61
Update ResponsivenessTesting.md
Raidakarim Jun 2, 2023
b149556
Update ResponsivenessTesting.md
Raidakarim Jun 2, 2023
9d8f5b2
Merge branch 'main' into raidak/responsiveness
Raidakarim Jun 2, 2023
0333a5f
Update ResponsivenessTesting.md
Raidakarim Jun 2, 2023
4cf2163
Merge branch 'raidak/responsiveness' of https://github.com/personalro…
Raidakarim Jun 2, 2023
4cf6592
custom hook and landscape for video
Raidakarim Jun 2, 2023
7fff015
review response
Raidakarim Jun 2, 2023
3b07978
Merge branch 'main' into raidak/responsiveness
Raidakarim Jun 2, 2023
3ece715
button width and height
Raidakarim Jun 2, 2023
33dbc0f
add footer width
Raidakarim Jun 3, 2023
d7f753f
width
Raidakarim Jun 3, 2023
dd52ef7
remove copied code in footer
Raidakarim Jun 3, 2023
7e50a30
add comments
Raidakarim Jun 3, 2023
543d184
variables of font size and wisth
Raidakarim Jun 3, 2023
7125ac4
change dependency
Raidakarim Jun 3, 2023
912a5fa
comma check done
Raidakarim Jun 4, 2023
af035d5
biteSelection position fix
Raidakarim Jun 4, 2023
8c57e76
fix variables
Raidakarim Jun 4, 2023
0ebac2f
add margin variable
Raidakarim Jun 4, 2023
96301e1
footer width adjust
Raidakarim Jun 4, 2023
b410b2d
variable in-line
Raidakarim Jun 5, 2023
28e676a
comments add
Raidakarim Jun 5, 2023
b041e36
add format
Raidakarim Jun 5, 2023
2269d88
add video in helper
Raidakarim Jun 5, 2023
6c667d5
callback add
Raidakarim Jun 5, 2023
8c7823b
useEffect for video and plateLocator lock
Raidakarim Jun 5, 2023
b286bb8
food image button fixes
Raidakarim Jun 6, 2023
4e656a0
acqusition button fix
Raidakarim Jun 6, 2023
7a54c03
bite done and seletion
Raidakarim Jun 6, 2023
378f924
skip button resize
Raidakarim Jun 6, 2023
4d0b652
skip fix
Raidakarim Jun 6, 2023
782f327
skip button space remove
Raidakarim Jun 6, 2023
70517b7
mask
Raidakarim Jun 7, 2023
cc65f0f
mask update
Raidakarim Jun 7, 2023
3ab00dc
add
Raidakarim Jun 7, 2023
51d4581
use percentage of size
Raidakarim Jun 7, 2023
0a3025c
mask updates
Raidakarim Jun 7, 2023
8589065
mask working now
Raidakarim Jun 8, 2023
c7c0a9d
some PR cooments responded
Raidakarim Jun 8, 2023
aacd031
progress bar and text auto-sizing
Raidakarim Jun 8, 2023
20401cf
make footer responsiveness and tested in all device
Raidakarim Jun 8, 2023
0441bad
adjust header sizes in vw vh
Raidakarim Jun 8, 2023
75f9614
add responsiveness changes
Raidakarim Jun 9, 2023
c7c1c63
some PR response
Raidakarim Jun 10, 2023
4251aa4
PR responses
Raidakarim Jun 11, 2023
2b2b696
Implemented vertical centering (#66)
amalnanavati Jun 11, 2023
2832936
add circle bar size
Raidakarim Jun 11, 2023
b3b5245
matching top bottom
Raidakarim Jun 11, 2023
8a39291
small fix
Raidakarim Jun 11, 2023
2e6f14d
footer fix
Raidakarim Jun 13, 2023
7646503
header fix
Raidakarim Jun 13, 2023
4ffcf28
add phantom view
Raidakarim Jun 13, 2023
c55fe3b
footer fix
Raidakarim Jun 13, 2023
8dbffd7
Fixed circle bar size on RobotMotion page (#68)
amalnanavati Jun 13, 2023
91f1d0e
responsiveness
Raidakarim Jun 15, 2023
fa2e4f5
add more
Raidakarim Jun 15, 2023
8807c59
small changes
Raidakarim Jun 15, 2023
0b4d05f
Fix Video Scaling Responsiveness (#69)
amalnanavati Jun 30, 2023
50513dc
remove phantom view from footer and robotmotion
Raidakarim Jun 30, 2023
dcc5c2b
helper add
Raidakarim Jun 30, 2023
8d3a1a1
PR response
Raidakarim Jul 1, 2023
eda4dd3
resizing
Raidakarim Jul 2, 2023
1f4a96a
fix after test
Raidakarim Jul 4, 2023
0864b6f
add vw
Raidakarim Jul 4, 2023
d725f56
lock fix
Raidakarim Jul 4, 2023
19d5131
add comments
Raidakarim Jul 5, 2023
6233348
add height fix
Raidakarim Jul 6, 2023
dda0206
height fix
Raidakarim Jul 7, 2023
b230f81
use windoe size
Raidakarim Jul 7, 2023
a4d3572
useWindowSize and header fix
Raidakarim Jul 9, 2023
35a6a19
Fix iOS 100vh Bug & Other Responsiveness Bugs (#71)
amalnanavati Jul 12, 2023
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
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- [ ] Format React code with `npm run format`
- [ ] Format Python code by running `python3 -m black .` in the top-level of this repository
- [ ] Thoroughly test your code's functionality, including unintended uses.
- [ ] Thoroughly test your code's responsiveness by rendering it on different devices, browsers, etc.
- [ ] Fully test the responsiveness of the feature as documented in the [Responsiveness Testing Guidelines](https://github.com/personalrobotics/feeding_web_interface/blob/main/feedingwebapp/ResponsivenessTesting.md). If you deviate from those guidelines, document above why you deviated and what you did instead.
- [ ] Consider the user flow between states that this feature introduces, consider different situations that might occur for the user, and ensure that there is no way for the user to get stuck in a loop.

**Before merging a pull request**
Expand Down
32 changes: 32 additions & 0 deletions feedingwebapp/ResponsivenessTesting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Methodology for Testing Responsiveness

After developing an app feature, make sure to test it on the following setups. Total 4 devices as listed below.
- **Smartphone:** iPhone 14 Plus [Tyler]; Width: 428 & Height: 926
- Landscape
- Portrait
- **Tablet:** iPad Pro (6th gen 12.9") [Tyler]; Width: 1024 & Height: 1366
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
- Landscape
- Portrait
- **External Monitor:** Width: 4096 & Height: 2304
- **Laptop:** Width: 2560 & Height: 1600
- Full-screen
- Half-screen (vertical split)
- Quarter screen

For the smartphone and laptops, test on Chrome, Firefox, Edge, and Safari. For the tablet and monitor, pick one browser to test it on.

In total, you will run 23 tests (4 browsers * 1 smartphone * 2 orientations + 1 tablet * 2 orientations + 4 browsers * 3 laptops + 1 monitor).

In portrait, pages should have their content appear on one screen and not require scrolling. In landscape, scrolling may be unavoidable for some screens, but try to rearrange the content horizontally in order to minimize required scrolling.
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved

If you don’t have the listed devices available for testing, please “Add custom device” in your browser’s responsive design mode using the width and height of the specific device’s resolution below. Please find the appropriate link from below for each browser's documentation on how to do this *except* Safari:

1. https://www.ios-resolution.com/
2. https://support.apple.com/kb/SP748?locale=en_US
3. Adding custom device in Chrome: https://developer.chrome.com/blog/add-a-new-custom-device-as-a-preset/
4. Adding custom device in Edge: https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/device-mode/
5. Adding custom device in Firefox:
https://firefox-source-docs.mozilla.org/devtools-user/responsive_design_mode/#creating-custom-devices



36 changes: 36 additions & 0 deletions feedingwebapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions feedingwebapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"react-dom": "^18.1.0",
"react-hook-form": "^7.43.9",
"react-native-web": "^0.19.4",
"react-responsive": "^9.0.2",
"react-router-dom": "^6.3.0",
"react-script-tag": "^1.1.2",
"react-scripts": "^5.0.1",
Expand Down
217 changes: 110 additions & 107 deletions feedingwebapp/src/Pages/Footer/Footer.jsx
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React, { useCallback } from 'react'
import { MDBFooter } from 'mdb-react-ui-kit'
import Button from 'react-bootstrap/Button'
import { View } from 'react-native'
import { useMediaQuery } from 'react-responsive'
import Row from 'react-bootstrap/Row'
// PropTypes is used to validate that the used props are in fact passed to this Component
import PropTypes from 'prop-types'

// Local imports
import { MOVING_STATE_ICON_DICT } from '../Constants'
import { useGlobalState } from '../GlobalState'
Expand All @@ -29,140 +29,143 @@ import { useGlobalState } from '../GlobalState'
const Footer = (props) => {
// Get the current meal state
const mealState = useGlobalState((state) => state.mealState)

// Icons and other parameters for the footer buttons
// Icons for the footer buttons
let pauseIcon = '/robot_state_imgs/pause_button_icon.svg'
let backIcon = props.backMealState ? MOVING_STATE_ICON_DICT[props.backMealState] : ''
let resumeIcon = MOVING_STATE_ICON_DICT[mealState]
let phantomButtonIcon = '/robot_state_imgs/phantom_view_image.svg'
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
// Width of Back and Resume buttons
let backResumeButtonWidth = '150px'
// Height of all Footer buttons
let footerButtonHeight = '100px'
// Flag to check if the current orientation is portrait
const isPortrait = useMediaQuery({ query: '(orientation: portrait)' })
// sizes for footer buttons and icons (width, height, fontsize)
let pauseButtonWidth = '98vw'
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
let backResumeButtonWidth = '47vw'
let footerHeight = isPortrait ? '10vh' : '10vw'
let pauseFontSize = isPortrait ? '7vh' : '7vw'
let backResumeFontSize = '6vw'
// Margins around footer buttons
let footerLeftRightMargin = isPortrait ? '1.6vh' : '1.6vw'
let footerTopBottomMargin = isPortrait ? '0.3vh' : '0.3vw'
// A single nested object with all footer buttons' properties
const buttonConfig = {
pause: {
text: 'Pause',
icon: pauseIcon,
disabled: false,
variant: 'danger',
callback: props.pauseCallback
},
back: {
text: 'Back',
icon: backIcon,
disabled: false,
variant: 'warning',
callback: props.backCallback
},
resume: {
text: 'Resume',
icon: resumeIcon,
disabled: false,
variant: 'success',
callback: props.resumeCallback
},
phantom: {
text: null,
icon: phantomButtonIcon,
disabled: true,
variant: 'ghost',
callback: null
}
}

/**
* Get the pause text and button to render in footer.
* Get the footer text and button to render in footer.
*
* @returns {JSX.Element} the pause text and button
* @param {number} config - a single nested object with properties of
*
* @returns {JSX.Element} the footer text and button
*/
const renderPauseButton = useCallback(
(callback) => {
const renderFooterButton = useCallback(
(config) => {
return (
<>
<Row className='justify-content-center mx-auto'>
<p className='transitionMessage' style={{ marginBottom: '0', fontSize: '170%', color: 'white', fontWeight: 'bold' }}>
Pause
</p>
{/* Icon to pause */}
<Row className='justify-content-center'>
<Button
variant='danger'
onClick={callback}
style={{ marginLeft: '10', marginRight: '10', marginTop: '0', width: '350px', height: { footerButtonHeight } }}
variant={config.variant}
disabled={config.disabled}
onClick={config.callback}
style={{
backgroundColor: config.text === null ? 'transparent' : null,
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
border: 'none',
marginTop: footerTopBottomMargin,
marginLeft: footerLeftRightMargin,
marginRight: footerLeftRightMargin,
marginBottom: footerTopBottomMargin,
width: config.text === 'Pause' ? pauseButtonWidth : backResumeButtonWidth,
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
height: footerHeight,
justifyContent: 'center',
alignItems: 'center',
'--bs-btn-padding-y': '0rem',
'--bs-btn-padding-x': '0rem'
}}
>
<img style={{ width: '135px', height: '90px' }} src={pauseIcon} alt='pause_icon' className='center' />
<View
style={{
flexDirection: 'row',
justifyContent: 'center'
}}
>
<View style={{ flex: 1, justifyContent: 'center' }}>
<p
className='transitionMessage'
style={{
marginBottom: '0',
fontSize: config.text === 'Pause' ? pauseFontSize : backResumeFontSize,
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
color: 'black',
fontWeight: 'bold',
padding: '0',
textAlign: 'right'
}}
>
{config.text}
</p>
</View>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'flex-start' }}>
<div style={{ textAlign: 'left' }}>
<img
style={{
width: '100%',
height: footerHeight
}}
src={config.icon}
alt='icon_img'
/>
</div>
</View>
</View>
</Button>
</Row>
</>
)
},
[pauseIcon, footerButtonHeight]
)

/**
* Get the back text and button to render in footer.
*
* @returns {JSX.Element} the back text and button
*/
const renderBackButton = useCallback(
(callback) => {
return (
<>
<p className='transitionMessage' style={{ marginBottom: '0', fontSize: '170%', color: 'white', fontWeight: 'bold' }}>
Back
</p>
{/* Icon to move to previous state */}
<Button
variant='warning'
onClick={callback}
style={{ marginLeft: 10, marginRight: 10, width: { backResumeButtonWidth }, height: { footerButtonHeight } }}
>
<img style={{ width: '120px', height: '72px' }} src={backIcon} alt='back_icon' className='center' />
</Button>
</>
)
},
[backIcon, backResumeButtonWidth, footerButtonHeight]
)

/**
* Get the resume text and button to render in footer.
*
* @returns {JSX.Element} the resume text and button
*/
const renderResumeButton = useCallback(
(callback) => {
return (
<>
<p className='transitionMessage' style={{ marginBottom: '0', fontSize: '170%', color: 'white', fontWeight: 'bold' }}>
Resume
</p>
{/* Icon to resume current state */}
<Button
variant='success'
onClick={callback}
style={{ marginLeft: 10, marginRight: 10, width: { backResumeButtonWidth }, height: { footerButtonHeight } }}
>
<img style={{ width: '120px', height: '72px' }} src={resumeIcon} alt='resume_icon' className='center' />
</Button>
</>
)
},
[resumeIcon, backResumeButtonWidth, footerButtonHeight]
[backResumeButtonWidth, pauseButtonWidth, pauseFontSize, backResumeFontSize, footerHeight, footerLeftRightMargin, footerTopBottomMargin]
)

/**
* Get the phantom view to render in footer. This is used as a placeholder
* when the back button or resume button are disabled.
*
* @returns {JSX.Element} the phantom view
*/
let renderPhantomButton = function () {
return (
<>
<Button
variant='ghost'
disabled={true}
style={{
backgroundColor: 'transparent',
border: 'none',
marginLeft: 10,
marginRight: 10,
width: { backResumeButtonWidth },
height: { footerButtonHeight }
}}
>
<img style={{ width: '120px', height: '72px' }} src={phantomButtonIcon} alt='phantom_button_img' className='center' />
</Button>
</>
)
}

// Render the component
return (
<>
<MDBFooter bgColor='dark' className='text-center text-lg-left fixed-bottom'>
<div className='text-center p-3' style={{ backgroundColor: 'rgba(0, 0, 0, 0.2)' }}>
<View>
<MDBFooter bgColor='dark' className='text-center text-lg-left' style={{ width: '100vw' }}>
<div className='text-center' style={{ backgroundColor: 'rgba(0, 0, 0, 0.2)', paddingBottom: '5px', paddingTop: '5px' }}>
{props.paused ? (
<View style={{ flexDirection: 'row', justifyContent: 'center' }}>
<View>{props.backCallback ? renderBackButton(props.backCallback) : renderPhantomButton()}</View>
<View>{props.resumeCallback ? renderResumeButton(props.resumeCallback) : renderPhantomButton()}</View>
<View>{props.backCallback ? renderFooterButton(buttonConfig.back) : renderFooterButton(buttonConfig.phantom)}</View>
<View>{props.resumeCallback ? renderFooterButton(buttonConfig.resume) : renderFooterButton(buttonConfig.phantom)}</View>
</View>
) : (
renderPauseButton(props.pauseCallback)
renderFooterButton(buttonConfig.pause)
)}
</div>
</MDBFooter>
</>
</View>
)
}
Footer.propTypes = {
Expand Down
Loading