import {
IonContent, IonHeader, IonPage, IonTitle, IonToolbar,
IonAlert, IonButton, IonCard, IonCardHeader,
IonCardSubtitle, IonCardTitle, IonCardContent,
IonItem, IonIcon, IonLabel, IonBadge, IonList,
IonItemDivider, IonCheckbox, IonChip, IonAvatar,
IonGrid, IonRow, IonCol, IonInput, IonToggle,
IonModal, IonRefresher, IonRefresherContent,
IonTextarea, IonSelect, IonListHeader,
IonSelectOption
} from '@ionic/react';
import ExploreContainer from '../components/ExploreContainer';
import './Tab1.css';
import { pin, heart, closeCircle, close } from 'ionicons/icons';
import { RefresherEventDetail } from '@ionic/core';
import axios from 'axios'
const Tab1: React.FC = () => {
const [toppings, setToppings] = useState<string[]>([]);
const [pets, setPets] = useState<string[]>(['bird', 'dog']);
return (
<IonPage>
<IonContent>
<IonList>
<IonListHeader>
<IonLabel>
Multiple Selection
</IonLabel>
</IonListHeader>
<IonItem>
<IonLabel>Toppings</IonLabel>
<IonSelect value={toppings} multiple={true} cancelText="Nah" okText="Okay!" onIonChange={e => setToppings(e.detail.value)}>
<IonSelectOption value="bacon">Bacon</IonSelectOption>
<IonSelectOption value="olives">Black Olives</IonSelectOption>
<IonSelectOption value="xcheese">Extra Cheese</IonSelectOption>
<IonSelectOption value="peppers">Green Peppers</IonSelectOption>
<IonSelectOption value="mushrooms">Mushrooms</IonSelectOption>
<IonSelectOption value="onions">Onions</IonSelectOption>
<IonSelectOption value="pepperoni">Pepperoni</IonSelectOption>
<IonSelectOption value="pineapple">Pineapple</IonSelectOption>
<IonSelectOption value="sausage">Sausage</IonSelectOption>
<IonSelectOption value="Spinach">Spinach</IonSelectOption>
</IonSelect>
</IonItem>
<IonItem>
<IonLabel>Pets</IonLabel>
<IonSelect multiple={true} value={pets} onIonChange={e => { setPets(e.detail.value); console.log(e.detail.value) }}>
<IonSelectOption value="bird">Bird</IonSelectOption>
<IonSelectOption value="cat">Cat</IonSelectOption>
<IonSelectOption value="dog">Dog</IonSelectOption>
<IonSelectOption value="honeybadger">Honey Badger</IonSelectOption>
</IonSelect>
</IonItem>
<IonItemDivider>Your Selections</IonItemDivider>
{/*sum up all elements in an array*/}
<IonItem>Toppings: {toppings.length ? toppings.reduce((curr, prev) => prev + ', ' + curr, '') : '(none selected)'}</IonItem>
<IonItem>Pets: {pets.length ? pets.reduce((curr, prev) => prev + ', ' + curr, '') : '(none selected)'}</IonItem>
</IonList>
</IonContent>
</IonPage>
);
};
export default Tab1;
No comments:
Post a Comment