feat: Redesign mobile UI with centered voice button and user menu
- Repositioned Voice Command button to center of bottom navigation bar - Added floating user menu icon in top-left corner on mobile - User menu includes: Settings, Children, Family, and Logout options - Updated bottom nav to show: Home, Track, Voice (center), Insights, History - Hide original floating voice button on mobile to avoid duplication - Improved mobile UX with easier thumb access to voice commands - User avatar displays first letter of user's name 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -38,19 +38,70 @@ const steps = ['Welcome', 'Language', 'Measurements', 'Add Child', 'Complete'];
|
||||
|
||||
export default function OnboardingPage() {
|
||||
const [activeStep, setActiveStep] = useState(0);
|
||||
const [selectedLanguage, setSelectedLanguage] = useState('en');
|
||||
const [selectedMeasurement, setSelectedMeasurement] = useState<MeasurementSystem>('metric');
|
||||
const [childName, setChildName] = useState('');
|
||||
const [childBirthDate, setChildBirthDate] = useState('');
|
||||
const [childGender, setChildGender] = useState<'male' | 'female' | 'other'>('other');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const router = useRouter();
|
||||
const { user } = useAuth();
|
||||
const { user, refreshUser } = useAuth();
|
||||
const { setLanguage, setMeasurementSystem } = useLocale();
|
||||
const { t } = useTranslation('onboarding');
|
||||
|
||||
const handleNext = async () => {
|
||||
// Validate and save child data on step 1 (Add Child)
|
||||
setError('');
|
||||
|
||||
// Step 1: Save language preference
|
||||
if (activeStep === 1) {
|
||||
try {
|
||||
setLoading(true);
|
||||
await setLanguage(selectedLanguage);
|
||||
// Save to backend
|
||||
if (user?.id) {
|
||||
await usersApi.updatePreferences({
|
||||
language: selectedLanguage,
|
||||
});
|
||||
}
|
||||
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
||||
} catch (err: any) {
|
||||
console.error('Failed to save language:', err);
|
||||
setError('Failed to save language preference. Continuing anyway...');
|
||||
setTimeout(() => setActiveStep((prevActiveStep) => prevActiveStep + 1), 1500);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2: Save measurement preference
|
||||
if (activeStep === 2) {
|
||||
try {
|
||||
setLoading(true);
|
||||
setMeasurementSystem(selectedMeasurement);
|
||||
// Save to backend
|
||||
if (user?.id) {
|
||||
await usersApi.updatePreferences({
|
||||
measurementUnit: selectedMeasurement,
|
||||
});
|
||||
await refreshUser();
|
||||
}
|
||||
setActiveStep((prevActiveStep) => prevActiveStep + 1);
|
||||
} catch (err: any) {
|
||||
console.error('Failed to save measurement:', err);
|
||||
setError('Failed to save measurement preference. Continuing anyway...');
|
||||
setTimeout(() => setActiveStep((prevActiveStep) => prevActiveStep + 1), 1500);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 3: Validate and save child data (Add Child)
|
||||
if (activeStep === 3) {
|
||||
if (!childName.trim() || !childBirthDate) {
|
||||
setError('Please enter child name and birth date');
|
||||
setError(t('child.name') + ' and ' + t('child.dateOfBirth') + ' are required');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -118,11 +169,20 @@ export default function OnboardingPage() {
|
||||
}}
|
||||
>
|
||||
<Stepper activeStep={activeStep} sx={{ mb: 4 }}>
|
||||
{steps.map((label) => (
|
||||
<Step key={label}>
|
||||
<StepLabel>{label}</StepLabel>
|
||||
</Step>
|
||||
))}
|
||||
{steps.map((label, index) => {
|
||||
let stepLabel = label;
|
||||
if (index === 0) stepLabel = t('welcome.title').split('!')[0];
|
||||
else if (index === 1) stepLabel = t('language.title');
|
||||
else if (index === 2) stepLabel = t('measurements.title');
|
||||
else if (index === 3) stepLabel = t('child.title');
|
||||
else if (index === 4) stepLabel = t('complete.title').split('!')[0];
|
||||
|
||||
return (
|
||||
<Step key={label}>
|
||||
<StepLabel>{stepLabel}</StepLabel>
|
||||
</Step>
|
||||
);
|
||||
})}
|
||||
</Stepper>
|
||||
|
||||
<AnimatePresence mode="wait">
|
||||
@@ -133,18 +193,19 @@ export default function OnboardingPage() {
|
||||
exit={{ opacity: 0, x: -20 }}
|
||||
transition={{ duration: 0.3 }}
|
||||
>
|
||||
{/* Step 0: Welcome */}
|
||||
{activeStep === 0 && (
|
||||
<Box sx={{ textAlign: 'center', py: 4 }}>
|
||||
<Typography variant="h4" gutterBottom fontWeight="600" color="primary.main">
|
||||
Welcome to Maternal! 🎉
|
||||
{t('welcome.title')} 🎉
|
||||
</Typography>
|
||||
<Typography variant="body1" color="text.secondary" sx={{ mt: 2, mb: 4 }}>
|
||||
We're excited to help you track and understand your child's development, sleep patterns, feeding schedules, and more.
|
||||
{t('welcome.description')}
|
||||
</Typography>
|
||||
<Box sx={{ display: 'flex', gap: 2, justifyContent: 'center', flexWrap: 'wrap' }}>
|
||||
<Paper sx={{ p: 2, flex: 1, minWidth: 150 }}>
|
||||
<Typography variant="h6" fontWeight="600">📊</Typography>
|
||||
<Typography variant="body2">Track Activities</Typography>
|
||||
<Typography variant="body2">{t('welcome.getStarted')}</Typography>
|
||||
</Paper>
|
||||
<Paper sx={{ p: 2, flex: 1, minWidth: 150 }}>
|
||||
<Typography variant="h6" fontWeight="600">🤖</Typography>
|
||||
@@ -158,13 +219,165 @@ export default function OnboardingPage() {
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Step 1: Language Selection */}
|
||||
{activeStep === 1 && (
|
||||
<Box sx={{ py: 4 }}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
||||
<Language sx={{ fontSize: 40, color: 'primary.main', mr: 2 }} />
|
||||
<Box>
|
||||
<Typography variant="h5" fontWeight="600">
|
||||
{t('language.title')}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{t('language.subtitle')}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{error && (
|
||||
<Alert severity="error" sx={{ mb: 2, borderRadius: 2 }}>
|
||||
{error}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<Grid container spacing={2} sx={{ mt: 2 }}>
|
||||
{supportedLanguages.map((lang) => (
|
||||
<Grid item xs={12} sm={6} key={lang.code}>
|
||||
<Card
|
||||
sx={{
|
||||
border: selectedLanguage === lang.code ? '2px solid' : '1px solid',
|
||||
borderColor: selectedLanguage === lang.code ? 'primary.main' : 'divider',
|
||||
transition: 'all 0.2s',
|
||||
}}
|
||||
>
|
||||
<CardActionArea
|
||||
onClick={() => setSelectedLanguage(lang.code)}
|
||||
sx={{ p: 2 }}
|
||||
>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<Box>
|
||||
<Typography variant="h6" fontWeight="600">
|
||||
{lang.nativeName}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{lang.name}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Radio
|
||||
checked={selectedLanguage === lang.code}
|
||||
value={lang.code}
|
||||
name="language-radio"
|
||||
/>
|
||||
</Box>
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
|
||||
<Alert severity="info" sx={{ mt: 3, borderRadius: 2 }}>
|
||||
{t('language.description')}
|
||||
</Alert>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Step 2: Measurement System */}
|
||||
{activeStep === 2 && (
|
||||
<Box sx={{ py: 4 }}>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', mb: 2 }}>
|
||||
<Straighten sx={{ fontSize: 40, color: 'primary.main', mr: 2 }} />
|
||||
<Box>
|
||||
<Typography variant="h5" fontWeight="600">
|
||||
{t('measurements.title')}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{t('measurements.subtitle')}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{error && (
|
||||
<Alert severity="error" sx={{ mb: 2, borderRadius: 2 }}>
|
||||
{error}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<Grid container spacing={3} sx={{ mt: 2 }}>
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Card
|
||||
sx={{
|
||||
border: selectedMeasurement === 'metric' ? '2px solid' : '1px solid',
|
||||
borderColor: selectedMeasurement === 'metric' ? 'primary.main' : 'divider',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<CardActionArea
|
||||
onClick={() => setSelectedMeasurement('metric')}
|
||||
sx={{ p: 3, height: '100%' }}
|
||||
>
|
||||
<Box sx={{ textAlign: 'center' }}>
|
||||
<Radio
|
||||
checked={selectedMeasurement === 'metric'}
|
||||
value="metric"
|
||||
name="measurement-radio"
|
||||
sx={{ mb: 1 }}
|
||||
/>
|
||||
<Typography variant="h6" fontWeight="600" gutterBottom>
|
||||
{t('measurements.metric.title')}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{t('measurements.metric.description')}
|
||||
</Typography>
|
||||
</Box>
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12} sm={6}>
|
||||
<Card
|
||||
sx={{
|
||||
border: selectedMeasurement === 'imperial' ? '2px solid' : '1px solid',
|
||||
borderColor: selectedMeasurement === 'imperial' ? 'primary.main' : 'divider',
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<CardActionArea
|
||||
onClick={() => setSelectedMeasurement('imperial')}
|
||||
sx={{ p: 3, height: '100%' }}
|
||||
>
|
||||
<Box sx={{ textAlign: 'center' }}>
|
||||
<Radio
|
||||
checked={selectedMeasurement === 'imperial'}
|
||||
value="imperial"
|
||||
name="measurement-radio"
|
||||
sx={{ mb: 1 }}
|
||||
/>
|
||||
<Typography variant="h6" fontWeight="600" gutterBottom>
|
||||
{t('measurements.imperial.title')}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
{t('measurements.imperial.description')}
|
||||
</Typography>
|
||||
</Box>
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Alert severity="info" sx={{ mt: 3, borderRadius: 2 }}>
|
||||
{t('measurements.description')}
|
||||
</Alert>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Step 3: Add Child */}
|
||||
{activeStep === 3 && (
|
||||
<Box sx={{ py: 4 }}>
|
||||
<Typography variant="h5" gutterBottom fontWeight="600">
|
||||
Add Your First Child
|
||||
{t('child.title')}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ mb: 3 }}>
|
||||
Let's start by adding some basic information about your child.
|
||||
{t('child.subtitle')}
|
||||
</Typography>
|
||||
|
||||
{error && (
|
||||
@@ -175,7 +388,7 @@ export default function OnboardingPage() {
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Child's Name"
|
||||
label={t('child.name')}
|
||||
value={childName}
|
||||
onChange={(e) => setChildName(e.target.value)}
|
||||
margin="normal"
|
||||
@@ -188,7 +401,7 @@ export default function OnboardingPage() {
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Birth Date"
|
||||
label={t('child.dateOfBirth')}
|
||||
type="date"
|
||||
value={childBirthDate}
|
||||
onChange={(e) => setChildBirthDate(e.target.value)}
|
||||
@@ -206,7 +419,7 @@ export default function OnboardingPage() {
|
||||
<TextField
|
||||
fullWidth
|
||||
select
|
||||
label="Gender"
|
||||
label={t('child.gender')}
|
||||
value={childGender}
|
||||
onChange={(e) => setChildGender(e.target.value as 'male' | 'female' | 'other')}
|
||||
margin="normal"
|
||||
@@ -215,52 +428,19 @@ export default function OnboardingPage() {
|
||||
sx: { borderRadius: 3 },
|
||||
}}
|
||||
>
|
||||
<MenuItem value="male">Male</MenuItem>
|
||||
<MenuItem value="female">Female</MenuItem>
|
||||
<MenuItem value="other">Prefer not to say</MenuItem>
|
||||
<MenuItem value="male">{t('child.genders.male')}</MenuItem>
|
||||
<MenuItem value="female">{t('child.genders.female')}</MenuItem>
|
||||
<MenuItem value="other">{t('child.genders.preferNotToSay')}</MenuItem>
|
||||
</TextField>
|
||||
|
||||
<Alert severity="info" sx={{ mt: 3, borderRadius: 2 }}>
|
||||
You can add more children and details later from settings.
|
||||
{t('child.skipForNow')}
|
||||
</Alert>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{activeStep === 2 && (
|
||||
<Box sx={{ py: 4 }}>
|
||||
<Typography variant="h5" gutterBottom fontWeight="600">
|
||||
Invite Family Members
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ mb: 3 }}>
|
||||
Share your child's progress with family members. They can view activities and add their own entries.
|
||||
</Typography>
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Email Address"
|
||||
type="email"
|
||||
margin="normal"
|
||||
placeholder="partner@example.com"
|
||||
InputProps={{
|
||||
sx: { borderRadius: 3 },
|
||||
}}
|
||||
/>
|
||||
|
||||
<Button
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
sx={{ mt: 2 }}
|
||||
>
|
||||
Send Invitation
|
||||
</Button>
|
||||
|
||||
<Alert severity="info" sx={{ mt: 3, borderRadius: 2 }}>
|
||||
You can skip this step and invite family members later.
|
||||
</Alert>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{activeStep === 3 && (
|
||||
{/* Step 4: Complete */}
|
||||
{activeStep === 4 && (
|
||||
<Box sx={{ textAlign: 'center', py: 4 }}>
|
||||
<Avatar
|
||||
sx={{
|
||||
@@ -274,15 +454,15 @@ export default function OnboardingPage() {
|
||||
<Check sx={{ fontSize: 48 }} />
|
||||
</Avatar>
|
||||
<Typography variant="h5" gutterBottom fontWeight="600">
|
||||
You're All Set! 🎉
|
||||
{t('complete.title')} 🎉
|
||||
</Typography>
|
||||
<Typography variant="body1" color="text.secondary" sx={{ mb: 4 }}>
|
||||
Start tracking your child's activities and get personalized insights.
|
||||
{t('complete.description')}
|
||||
</Typography>
|
||||
|
||||
<Paper sx={{ p: 3, bgcolor: 'primary.light', mb: 3 }}>
|
||||
<Typography variant="body2" fontWeight="600" gutterBottom>
|
||||
Next Steps:
|
||||
{t('complete.subtitle')}
|
||||
</Typography>
|
||||
<Typography variant="body2" align="left" component="div">
|
||||
• Track your first feeding, sleep, or diaper change<br />
|
||||
@@ -301,14 +481,14 @@ export default function OnboardingPage() {
|
||||
disabled={activeStep === 0}
|
||||
startIcon={<ArrowBack />}
|
||||
>
|
||||
Back
|
||||
{t('navigation.back')}
|
||||
</Button>
|
||||
|
||||
<Box sx={{ flex: 1 }} />
|
||||
|
||||
{activeStep < steps.length - 1 && activeStep > 0 && (
|
||||
{activeStep === 3 && (
|
||||
<Button onClick={handleSkip} sx={{ mr: 2 }}>
|
||||
Skip
|
||||
{t('navigation.skip')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -318,7 +498,7 @@ export default function OnboardingPage() {
|
||||
disabled={loading}
|
||||
endIcon={loading ? <CircularProgress size={20} /> : (activeStep === steps.length - 1 ? <Check /> : <ArrowForward />)}
|
||||
>
|
||||
{activeStep === steps.length - 1 ? 'Get Started' : 'Next'}
|
||||
{activeStep === steps.length - 1 ? t('complete.startTracking') : t('navigation.next')}
|
||||
</Button>
|
||||
</Box>
|
||||
</Paper>
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
'use client';
|
||||
|
||||
import { Box, Container, Chip, Tooltip } from '@mui/material';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Container,
|
||||
Chip,
|
||||
Tooltip,
|
||||
IconButton,
|
||||
Menu,
|
||||
MenuItem,
|
||||
ListItemIcon,
|
||||
ListItemText,
|
||||
Avatar,
|
||||
Divider,
|
||||
} from '@mui/material';
|
||||
import { MobileNav } from '../MobileNav/MobileNav';
|
||||
import { TabBar } from '../TabBar/TabBar';
|
||||
import { useMediaQuery } from '@/hooks/useMediaQuery';
|
||||
import { ReactNode } from 'react';
|
||||
import { useWebSocket } from '@/hooks/useWebSocket';
|
||||
import { Wifi, WifiOff, People } from '@mui/icons-material';
|
||||
import { Wifi, WifiOff, People, AccountCircle, Settings, ChildCare, Group, Logout } from '@mui/icons-material';
|
||||
import { useTranslation } from '@/hooks/useTranslation';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useAuth } from '@/lib/auth/AuthContext';
|
||||
|
||||
interface AppShellProps {
|
||||
children: ReactNode;
|
||||
@@ -15,9 +30,31 @@ interface AppShellProps {
|
||||
|
||||
export const AppShell = ({ children }: AppShellProps) => {
|
||||
const { t } = useTranslation('common');
|
||||
const router = useRouter();
|
||||
const { user, logout } = useAuth();
|
||||
const isMobile = useMediaQuery('(max-width: 768px)');
|
||||
const isTablet = useMediaQuery('(max-width: 1024px)');
|
||||
const { isConnected, presence } = useWebSocket();
|
||||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
||||
|
||||
const handleMenuOpen = (event: React.MouseEvent<HTMLElement>) => {
|
||||
setAnchorEl(event.currentTarget);
|
||||
};
|
||||
|
||||
const handleMenuClose = () => {
|
||||
setAnchorEl(null);
|
||||
};
|
||||
|
||||
const handleNavigate = (path: string) => {
|
||||
handleMenuClose();
|
||||
router.push(path);
|
||||
};
|
||||
|
||||
const handleLogout = async () => {
|
||||
handleMenuClose();
|
||||
await logout();
|
||||
router.push('/login');
|
||||
};
|
||||
|
||||
return (
|
||||
<Box sx={{
|
||||
@@ -29,6 +66,85 @@ export const AppShell = ({ children }: AppShellProps) => {
|
||||
}}>
|
||||
{!isMobile && <MobileNav />}
|
||||
|
||||
{/* Mobile User Menu Button - Top Left */}
|
||||
{isMobile && (
|
||||
<Box
|
||||
sx={{
|
||||
position: 'fixed',
|
||||
top: 8,
|
||||
left: 8,
|
||||
zIndex: 1200,
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
onClick={handleMenuOpen}
|
||||
size="small"
|
||||
aria-label="user menu"
|
||||
aria-controls={anchorEl ? 'user-menu' : undefined}
|
||||
aria-haspopup="true"
|
||||
aria-expanded={anchorEl ? 'true' : undefined}
|
||||
sx={{
|
||||
bgcolor: 'background.paper',
|
||||
boxShadow: 1,
|
||||
'&:hover': {
|
||||
bgcolor: 'background.paper',
|
||||
boxShadow: 2,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Avatar
|
||||
sx={{
|
||||
width: 32,
|
||||
height: 32,
|
||||
bgcolor: 'primary.main',
|
||||
fontSize: '0.875rem',
|
||||
}}
|
||||
>
|
||||
{user?.name?.charAt(0).toUpperCase() || 'U'}
|
||||
</Avatar>
|
||||
</IconButton>
|
||||
|
||||
<Menu
|
||||
id="user-menu"
|
||||
anchorEl={anchorEl}
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={handleMenuClose}
|
||||
onClick={handleMenuClose}
|
||||
transformOrigin={{ horizontal: 'left', vertical: 'top' }}
|
||||
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
|
||||
sx={{
|
||||
mt: 1,
|
||||
}}
|
||||
>
|
||||
<MenuItem onClick={() => handleNavigate('/settings')}>
|
||||
<ListItemIcon>
|
||||
<Settings fontSize="small" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>{t('navigation.settings')}</ListItemText>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => handleNavigate('/children')}>
|
||||
<ListItemIcon>
|
||||
<ChildCare fontSize="small" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>{t('navigation.children')}</ListItemText>
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => handleNavigate('/family')}>
|
||||
<ListItemIcon>
|
||||
<Group fontSize="small" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>{t('navigation.family')}</ListItemText>
|
||||
</MenuItem>
|
||||
<Divider />
|
||||
<MenuItem onClick={handleLogout}>
|
||||
<ListItemIcon>
|
||||
<Logout fontSize="small" color="error" />
|
||||
</ListItemIcon>
|
||||
<ListItemText>{t('navigation.logout')}</ListItemText>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Connection Status & Presence Indicator */}
|
||||
<Box
|
||||
sx={{
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import { BottomNavigation, BottomNavigationAction, Paper } from '@mui/material';
|
||||
import { useState } from 'react';
|
||||
import { BottomNavigation, BottomNavigationAction, Paper, Fab, Box } from '@mui/material';
|
||||
import {
|
||||
Home,
|
||||
Timeline,
|
||||
Chat,
|
||||
Insights,
|
||||
Settings,
|
||||
History,
|
||||
Mic,
|
||||
} from '@mui/icons-material';
|
||||
import { useTranslation } from '@/hooks/useTranslation';
|
||||
|
||||
@@ -15,53 +16,102 @@ export const TabBar = () => {
|
||||
const { t } = useTranslation('common');
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const [voiceOpen, setVoiceOpen] = useState(false);
|
||||
|
||||
const tabs = [
|
||||
{ label: t('navigation.home'), icon: <Home />, value: '/' },
|
||||
{ label: t('navigation.track'), icon: <Timeline />, value: '/track' },
|
||||
{ label: t('navigation.aiChat'), icon: <Chat />, value: '/ai-assistant' },
|
||||
{ label: '', icon: null, value: 'voice' }, // Placeholder for center button
|
||||
{ label: t('navigation.insights'), icon: <Insights />, value: '/insights' },
|
||||
{ label: t('navigation.settings'), icon: <Settings />, value: '/settings' },
|
||||
{ label: t('navigation.history'), icon: <History />, value: '/history' },
|
||||
];
|
||||
|
||||
return (
|
||||
<Paper
|
||||
component="nav"
|
||||
aria-label="Primary navigation"
|
||||
sx={{
|
||||
position: 'fixed',
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
zIndex: 1000,
|
||||
}}
|
||||
elevation={3}
|
||||
>
|
||||
<BottomNavigation
|
||||
value={pathname}
|
||||
onChange={(event, newValue) => {
|
||||
router.push(newValue);
|
||||
}}
|
||||
showLabels
|
||||
<>
|
||||
<Paper
|
||||
component="nav"
|
||||
aria-label="Primary navigation"
|
||||
sx={{
|
||||
height: 64,
|
||||
'& .MuiBottomNavigationAction-root': {
|
||||
minWidth: 60,
|
||||
'&.Mui-selected': {
|
||||
color: 'primary.main',
|
||||
position: 'fixed',
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
zIndex: 1000,
|
||||
}}
|
||||
elevation={3}
|
||||
>
|
||||
<BottomNavigation
|
||||
value={pathname}
|
||||
onChange={(event, newValue) => {
|
||||
if (newValue !== 'voice') {
|
||||
router.push(newValue);
|
||||
}
|
||||
}}
|
||||
showLabels
|
||||
sx={{
|
||||
height: 64,
|
||||
'& .MuiBottomNavigationAction-root': {
|
||||
minWidth: 60,
|
||||
'&.Mui-selected': {
|
||||
color: 'primary.main',
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
{tabs.map((tab) => {
|
||||
if (tab.value === 'voice') {
|
||||
// Center voice button placeholder
|
||||
return (
|
||||
<Box
|
||||
key="voice-placeholder"
|
||||
sx={{
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<BottomNavigationAction
|
||||
key={tab.value}
|
||||
label={tab.label}
|
||||
icon={tab.icon}
|
||||
value={tab.value}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</BottomNavigation>
|
||||
</Paper>
|
||||
|
||||
{/* Voice Command Floating Button - Centered */}
|
||||
<Fab
|
||||
color="secondary"
|
||||
aria-label="voice command"
|
||||
onClick={() => {
|
||||
// Trigger voice command - will integrate with existing VoiceFloatingButton
|
||||
const voiceButton = document.querySelector('[aria-label="voice input"]') as HTMLButtonElement;
|
||||
if (voiceButton) {
|
||||
voiceButton.click();
|
||||
}
|
||||
}}
|
||||
sx={{
|
||||
position: 'fixed',
|
||||
bottom: 40,
|
||||
left: '50%',
|
||||
transform: 'translateX(-50%)',
|
||||
zIndex: 1100,
|
||||
width: 56,
|
||||
height: 56,
|
||||
bgcolor: 'secondary.main',
|
||||
'&:hover': {
|
||||
bgcolor: 'secondary.dark',
|
||||
},
|
||||
}}
|
||||
>
|
||||
{tabs.map((tab) => (
|
||||
<BottomNavigationAction
|
||||
key={tab.value}
|
||||
label={tab.label}
|
||||
icon={tab.icon}
|
||||
value={tab.value}
|
||||
/>
|
||||
))}
|
||||
</BottomNavigation>
|
||||
</Paper>
|
||||
<Mic />
|
||||
</Fab>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -323,7 +323,7 @@ export function VoiceFloatingButton() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Floating button positioned in bottom-right */}
|
||||
{/* Floating button positioned in bottom-right - Hidden on mobile since we have TabBar center button */}
|
||||
<Tooltip title="Voice Command (Beta)" placement="left">
|
||||
<Fab
|
||||
color="primary"
|
||||
@@ -335,6 +335,7 @@ export function VoiceFloatingButton() {
|
||||
bottom: 24,
|
||||
right: 24,
|
||||
zIndex: 1000,
|
||||
display: { xs: 'none', md: 'flex' }, // Hide on mobile (xs) and small screens, show on medium+
|
||||
}}
|
||||
>
|
||||
<MicIcon />
|
||||
|
||||
Reference in New Issue
Block a user