| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- /**
- * Sample React Native App
- * https://github.com/facebook/react-native
- *
- * @format
- * @flow strict-local
- */
- import React from 'react';
- import type {Node} from 'react';
- import {
- Alert,
- Button,
- SafeAreaView,
- ScrollView,
- StatusBar,
- StyleSheet,
- Text,
- useColorScheme,
- View,
- } from 'react-native';
- import {
- Colors,
- DebugInstructions,
- Header,
- LearnMoreLinks,
- ReloadInstructions,
- } from 'react-native/Libraries/NewAppScreen';
- import Toolbar from './app/components/toolbar';
- import Dialog from './app/components/Dialog';
- const Section = ({children, title}): Node => {
- const isDarkMode = useColorScheme() === 'dark';
- return (
- <View style={styles.sectionContainer}>
- <Text
- style={[
- styles.sectionTitle,
- {
- color: isDarkMode ? Colors.white : Colors.black,
- },
- ]}>
- {title}
- </Text>
- <Text
- style={[
- styles.sectionDescription,
- {
- color: isDarkMode ? Colors.light : Colors.dark,
- },
- ]}>
- {children}
- </Text>
- </View>
- );
- };
- const App: () => Node = () => {
- const isDarkMode = useColorScheme() === 'dark';
- const backgroundStyle = {
- backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
- };
- return (
- <SafeAreaView style={backgroundStyle}>
- <Toolbar/>
- <ScrollView
- contentInsetAdjustmentBehavior="automatic"
- style={backgroundStyle}>
- <Header />
- <View
- style={{
- backgroundColor: isDarkMode ? Colors.black : Colors.white,
- }}>
- <Section title="Step One 1">
- Edit <Text style={styles.highlight}>App.js</Text> to change this
- screen and then come back to see your edits.
- </Section>
- <Button
- style={{
- height: 120,
- backgroundColor: Colors.black,
- }}
- onPress={() => {
- requestAnimationFrame(() => {
- Dialog.showDialog({title:'邠心', message:'Hello World!', callback:() => {
- toastShort('试试就试试')
- }});
- });
- }}
- title="点我试试"
- />
- <View style={{padding: 16}}>
- <Button onPress={() => {
- console.log('navigator', navigator)
- console.log('geolocation', navigator.geolocation)
- this.navigator.geolocation.getCurrentPosition((location) => {
- let latlng = {
- latitude: location.coords.latitude,
- longitude: location.coords.longitude,
- latitudeDelta: 0.0922,
- longitudeDelta: 0.0421,
- }
- Dialog.showDialog({title: 'Geolocation', message: JSON.stringify(latlng)})
- })
- }} title='定位'/>
- </View>
-
- <Section title="See Your Changes">
- <ReloadInstructions />
- </Section>
- <Section title="Debug">
- <DebugInstructions />
- </Section>
- <Section title="Learn More">
- Read the docs to discover what to do next:
- </Section>
- <LearnMoreLinks />
- </View>
- </ScrollView>
- </SafeAreaView>
- );
- };
- const styles = StyleSheet.create({
- sectionContainer: {
- marginTop: 32,
- paddingHorizontal: 24,
- },
- sectionTitle: {
- fontSize: 24,
- fontWeight: '600',
- },
- sectionDescription: {
- marginTop: 8,
- fontSize: 18,
- fontWeight: '400',
- },
- highlight: {
- fontWeight: '700',
- },
- });
- export default App;
|