import React from 'react';
import { View, Button, NativeModules, StyleSheet, Text } from 'react-native';

const { ToastModule } = NativeModules;

const CustomScreen = () => {
  const showToast = () => {
    ToastModule.showToast('Hello from Kotlin!', 1); // 1=长时，0=短时
  };

  const getDeviceName = () => {
    const device = ToastModule.getDeviceName();
    alert(`Device: ${device}`);
  };

  return (
    <View style={styles.container}>
      <Button title="显示 Toast" onPress={showToast} />
      <View style={styles.space} />
      <Button title="获取设备名称" onPress={getDeviceName} />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    padding: 20
  },
  space: {
    height: 10
  }
});

export default CustomScreen;