Examples
Meeting invite
A new meeting: when (date and time in one field, in 15-minute steps), how long, which time zone, and who's invited, picked as chips. Send invite sums it up.
Loading…
import { useState } from 'react'; import { ScrollView, StyleSheet, View } from 'react-native'; import { Button, DateTimePickerField, formatDate, Heading, SegmentedControl, Select, Text, useTheme } from 'patine-ui'; const LENGTHS = [15, 30, 45, 60].map((minutes) => ({ label: `${minutes} min`, value: minutes })); const ZONES = ['Lisbon · WET', 'London · GMT', 'New York · EST', 'Tel Aviv · IST', 'Tokyo · JST'].map((label) => ({ label, value: label })); const PEOPLE = [ { label: 'Maya Levi', value: 'maya', description: 'Design' }, { label: 'Rafael Mendes', value: 'rafael', description: 'Engineering' }, { label: 'Lea Martin', value: 'lea', description: 'Engineering' }, { label: 'Omer Katz', value: 'omer', description: 'Product' }, { label: 'Yuki Tanaka', value: 'yuki', description: 'Research' }, { label: 'Dana Cohen', value: 'dana', description: 'Marketing' }, ]; const inThreeDays = () => { const day = new Date(); day.setDate(day.getDate() + 3); day.setHours(10, 30, 0, 0); return day; }; export default function MeetingInvite() { const { colors } = useTheme(); const [when, setWhen] = useState(inThreeDays); const [length, setLength] = useState(30); const [zone, setZone] = useState<string | null>('Lisbon · WET'); const [guests, setGuests] = useState(['maya', 'rafael']); const [sending, setSending] = useState(false); const [sent, setSent] = useState(false); const send = () => { setSending(true); setTimeout(() => { setSending(false); setSent(true); }, 1000); }; return ( <View style={[styles.screen, { backgroundColor: colors.background }]}> <ScrollView contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled"> <View style={styles.titles}> <Heading level={2}>New meeting</Heading> <Text color="textSecondary"> {formatDate(when, undefined, { weekday: 'long', hour: 'numeric', minute: '2-digit' })} · {length} min · {guests.length} guests </Text> </View> <DateTimePickerField label="When" value={when} onConfirm={setWhen} minuteInterval={15} /> <Text weight="medium">Length</Text> <SegmentedControl items={LENGTHS} value={length} onValueChange={setLength} accessibilityLabel="Length" /> <Select label="Time zone" options={ZONES} value={zone} onValueChange={setZone} /> <Select label="Guests" options={PEOPLE} multiple chips value={guests} onValueChange={setGuests} searchable /> </ScrollView> <View style={styles.footer}> <Button size="lg" loading={sending} disabled={!guests.length} onPress={send}> {sent ? 'Invite sent' : `Send invite to ${guests.length}`} </Button> </View> </View> ); } const styles = StyleSheet.create({ screen: { flex: 1 }, content: { gap: 14, padding: 20 }, titles: { gap: 4, marginBottom: 4 }, footer: { padding: 16 }, });
Components used
- DateTimePickerField: the date and the time in one field, with
minuteInterval - SegmentedControl: the length
- Select: the time zone, and the guests with
multiple,chipsandsearchable - Button, Heading, Text
How it works
- One field for when.
DateTimePickerFieldopens a date and a time together, wheels on iOS, a calendar then a clock in Material, and a dropdown on the web, and confirms both at once. - Guests as chips. With
multipleandchips, each pick shows in the field and can be removed there. - Store the time zone with the meeting. The
Dateis the moment; the zone says how to show it to everyone else.