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 3 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
109 changes: 56 additions & 53 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
@@ -1,5 +1,5 @@
// React imports
import React from 'react'
import React, { useCallback } from 'react'
import { MDBFooter } from 'mdb-react-ui-kit'
import Button from 'react-bootstrap/Button'
import { View } from 'react-native'
Expand Down Expand Up @@ -39,69 +39,71 @@ const Footer = (props) => {
// 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 ? '11vh' : '11vw'
let footerHeight = isPortrait ? '10vh' : '10vw'
let pauseFontSize = isPortrait ? '7vh' : '7vw'
let backResumeFontSize = '6vw'
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
// Margins around footer buttons
let footerLeftRightMargin = isPortrait ? '1.5vh' : '1.5vw'
let footerLeftRightMargin = isPortrait ? '1.6vh' : '1.6vw'
let footerTopBottomMargin = isPortrait ? '0.3vh' : '0.3vw'
// Text list for footer buttons
const texts = ['Pause', 'Back', 'Resume']
// Icon list for footer buttons
const icons = [pauseIcon, backIcon, resumeIcon]
// Variant list for footer buttons
const variants = ['danger', 'warning', 'success']
// font sizes for footer button texts
const fontSizes = [pauseFontSize, backResumeFontSize, backResumeFontSize]
// button widths for footer
const buttonWidths = [pauseButtonWidth, backResumeButtonWidth, backResumeButtonWidth]
// callback functions for footer button click
const callbacks = [props.pauseCallback, props.backCallback, props.resumeCallback]
// 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 footer text and button to render in footer.
*
* @param {number} config - a single nested object with properties of
*
* @returns {JSX.Element} the footer text and button
*/
function renderFooterButton(index) {
if (index === 3) {
return (
<>
<Button
variant='ghost'
disabled={true}
style={{
backgroundColor: 'transparent',
border: 'none',
marginTop: footerTopBottomMargin,
marginLeft: footerLeftRightMargin,
marginRight: footerLeftRightMargin,
marginBottom: footerTopBottomMargin,
width: backResumeButtonWidth,
height: footerHeight,
'--bs-btn-padding-y': '0rem'
}}
>
<img style={{ width: '100%', height: footerHeight }} src={phantomButtonIcon} alt='phantom_button_img' className='center' />
</Button>
</>
)
} else {
const renderFooterButton = useCallback(
(config) => {
return (
<>
<Row className='justify-content-center'>
<Button
variant={variants[index]}
onClick={callbacks[index]}
variant={config.variant}
disabled={config.disabled}
onClick={config.callback}
style={{
width: buttonWidths[index],
justifyContent: 'center',
alignItems: 'center',
height: footerHeight,
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'
}}
Expand All @@ -117,14 +119,14 @@ const Footer = (props) => {
className='transitionMessage'
style={{
marginBottom: '0',
fontSize: fontSizes[index],
fontSize: config.text === 'Pause' ? pauseFontSize : backResumeFontSize,
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
color: 'black',
fontWeight: 'bold',
padding: '0',
textAlign: 'right'
}}
>
{texts[index]}
{config.text}
</p>
</View>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'flex-start' }}>
Expand All @@ -134,7 +136,7 @@ const Footer = (props) => {
width: '100%',
height: footerHeight
}}
src={icons[index]}
src={config.icon}
alt='icon_img'
/>
</div>
Expand All @@ -144,8 +146,9 @@ const Footer = (props) => {
</Row>
</>
)
}
}
},
[backResumeButtonWidth, pauseButtonWidth, pauseFontSize, backResumeFontSize, footerHeight, footerLeftRightMargin, footerTopBottomMargin]
)

// Render the component
return (
Expand All @@ -154,11 +157,11 @@ const Footer = (props) => {
<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 ? renderFooterButton(1) : renderFooterButton(3)}</View>
<View>{props.resumeCallback ? renderFooterButton(2) : renderFooterButton(3)}</View>
<View>{props.backCallback ? renderFooterButton(buttonConfig.back) : renderFooterButton(buttonConfig.phantom)}</View>
<View>{props.resumeCallback ? renderFooterButton(buttonConfig.resume) : renderFooterButton(buttonConfig.phantom)}</View>
</View>
) : (
renderFooterButton(0)
renderFooterButton(buttonConfig.pause)
)}
</div>
</MDBFooter>
Expand Down
141 changes: 52 additions & 89 deletions feedingwebapp/src/Pages/Header/Header.jsx
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 @@ -22,32 +22,23 @@ import LiveVideoModal from './LiveVideoModal'

/**
* The Header component consists of the navigation bar (which has buttons Home,
* Settings, Plate Locator, Done Eating, Lock Icon and Robot Connection Icon and Video).
* Live video view is toggled on and off by clicking "Video", and the ToastContainer
* popup that specifies when the user cannot click Settings.
*
* In addition to selecting their desired food item, the user has two
* other options on the header:
* - If their desired food item is not visible on the plate, they can
* decide to teleoperate the robot until it is visible.
* - Instead of selecting their next bite, the user can indicate that
* they are done eating.
* */
* Settings, Lock and Robot Connection Icon and Video). Live video view is toggled on and off by
* clicking "Video", and the ToastContainer popup that specifies when the user
* cannot click Settings.
*/
const Header = (props) => {
// Create a local state variable to toggle on/off the video
// TODO: Since this local state variable is in the header, the LiveVideoModal
// continues showing even if the state changes. Is this desirable? Perhaps
// it should close if the state changes?
const [videoShow, setVideoShow] = useState(false)
// Get the relevant global variables
const setMealState = useGlobalState((state) => state.setMealState)
// useROS gives us access to functions to configure and interact with ROS.
let { ros } = useROS()
const [isConnected, setIsConncected] = useState(ros.isConnected)
// Flag to check if the current orientation is portrait
const isPortrait = useMediaQuery({ query: '(orientation: portrait)' })
// Sizes of header elements (fontSize, width, height)
let textFontSize = isPortrait ? '1.9vh' : '1.9vw'
let textFontSize = isPortrait ? '2.5vh' : '2.5vw'
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
let lockIconWidth = isPortrait ? '4vh' : '4vw'
let lockIconHeight = isPortrait ? '5vh' : '5vw'
let lockImageHeight = isPortrait ? '4vh' : '4vw'
Expand All @@ -74,24 +65,6 @@ const Header = (props) => {
setAppPage(APP_PAGE.Home)
}, [setAppPage])

/**
* Callback function for when the user indicates that they want to move the
* robot to locate the plate.
*/
const locatePlateClicked = useCallback(() => {
console.log('locatePlateClicked')
setMealState(MEAL_STATE.U_PlateLocator)
}, [setMealState])

/**
* Callback function for when the user indicates that they are done with their
* meal.
*/
const doneEatingClicked = useCallback(() => {
console.log('doneEatingClicked')
setMealState(MEAL_STATE.R_StowingArm)
}, [setMealState])

/**
* When the Settings button in the header is clicked, if the meal has not yet
* started, take the user to the settings menu. Else, ask them to complete
Expand All @@ -112,10 +85,12 @@ const Header = (props) => {
* The ToastContainer is an alert that pops up on the top of the screen
* and has a timeout.
*/}
<ToastContainer style={{ fontSize: '4vh' }} />
<ToastContainer style={{ fontSize: textFontSize }} />
{/**
* The NavBar has five elements, Home and Settings, on the left side and three
* elements: Lock Icon, Robot Connection Status Icon, and Video; on the right side.
* The NavBar has two elements, Home and Settings, on the left side and three
* elements, Lock, Robot Connection Icon and VideoVideo, on the right side.
* An image showing the connection status
* of the robot is placed in between Lock and Video.
*/}
<Navbar
collapseOnSelect
Expand All @@ -131,7 +106,7 @@ const Header = (props) => {
variant='dark'
style={{ '--bs-navbar-padding-x': '0rem', '--bs-navbar-padding-y': '0.2rem' }}
>
<Nav className='m-auto'>
<Nav className='me-auto'>
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
<Nav.Link
onClick={homeClicked}
className='text-dark bg-info border border-info rounded mx-1 btn-lg btn-huge p-2'
Expand All @@ -146,59 +121,47 @@ const Header = (props) => {
>
Settings
</Nav.Link>
<Nav.Link
onClick={locatePlateClicked}
className='text-dark bg-info border border-info rounded mx-1 btn-lg btn-huge p-2'
style={{ fontSize: textFontSize }}
>
🍽️
</Nav.Link>
<Nav.Link
onClick={doneEatingClicked}
className='text-dark bg-info border border-info rounded mx-1 btn-lg btn-huge p-2'
style={{ fontSize: textFontSize }}
>
</Nav.Link>
{NON_MOVING_STATES.has(mealState) || paused || (mealState === MEAL_STATE.U_PlateLocator && teleopIsMoving === false) ? (
<div>
<Button
variant='danger'
disabled={true}
style={{
marginLeft: headerMargin,
marginRight: headerMargin,
width: lockIconWidth,
height: lockIconHeight,
opacity: 1,
'--bs-btn-padding-y': '0rem',
'--bs-btn-padding-x': '0rem'
}}
>
<img
style={{ width: lockIconWidth, height: lockImageHeight }}
src='/robot_state_imgs/lock_icon_image.svg'
alt='lock_icon_img'
className='center'
/>
</Button>
</div>
) : (
<></>
)}
{isConnected ? (
<div>
<p className='connectedDiv' style={{ fontSize: textFontSize, margin: headerMargin }}>
🔌
</p>
</div>
) : (
<div>
<p className='notConnectedDiv' style={{ fontSize: textFontSize, marginLeft: headerMargin, marginRight: headerMargin }}>
</p>
</div>
)}
</Nav>
{NON_MOVING_STATES.has(mealState) || paused || (mealState === MEAL_STATE.U_PlateLocator && teleopIsMoving === false) ? (
<div>
<Button
variant='danger'
disabled={true}
style={{
marginLeft: headerMargin,
marginRight: headerMargin,
width: lockIconWidth,
height: lockIconHeight,
opacity: 1,
'--bs-btn-padding-y': '0rem',
'--bs-btn-padding-x': '0rem'
}}
>
<img
style={{ width: lockIconWidth, height: lockImageHeight }}
src='/robot_state_imgs/lock_icon_image.svg'
alt='lock_icon_img'
className='center'
/>
</Button>
</div>
) : (
<></>
)}
{isConnected ? (
<div>
<p className='connectedDiv' style={{ fontSize: textFontSize, margin: headerMargin }}>
🔌
</p>
</div>
) : (
<div>
<p className='notConnectedDiv' style={{ fontSize: textFontSize, marginLeft: headerMargin, marginRight: headerMargin }}>
</p>
</div>
)}
<Nav>
<Nav.Link
onClick={() => setVideoShow(true)}
className='text-dark bg-info border border-info rounded mx-1 btn-lg btn-huge p-2'
Expand Down
7 changes: 6 additions & 1 deletion feedingwebapp/src/Pages/Header/LiveVideoModal.jsx
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// React imports
import React, { useEffect, useRef, useState } from 'react'
import { useMediaQuery } from 'react-responsive'
// The Modal is a screen that appears on top of the main app, and can be toggled
// on and off.
import Modal from 'react-bootstrap/Modal'
Expand Down Expand Up @@ -34,6 +35,8 @@ function LiveVideoModal(props) {
// Define variables for width and height of video
const [width, setWidth] = useState(windowSize.width)
const [height, setHeight] = useState(windowSize.height)
Raidakarim marked this conversation as resolved.
Show resolved Hide resolved
// Flag to check if the current orientation is portrait
const isPortrait = useMediaQuery({ query: '(orientation: portrait)' })

// Update the image size when the screen changes size.
useEffect(() => {
Expand Down Expand Up @@ -65,7 +68,9 @@ function LiveVideoModal(props) {
fullscreen={true}
>
<Modal.Header closeButton>
<Modal.Title id='contained-modal-title-vcenter'>Live Video</Modal.Title>
<Modal.Title id='contained-modal-title-vcenter' style={{ fontSize: isPortrait ? '3vh' : '3vw' }}>
Live Video
</Modal.Title>
</Modal.Header>
<Modal.Body style={{ overflow: 'hidden' }}>
<center>{showVideo(props.webVideoServerURL, width, height, null)}</center>
Expand Down
Loading