var React = require("react");
var View = require("react-native").View;
var Text = require("react-native").Text;
var AppRegistry = require("react-native").AppRegistry;
var Updates = require("expo-updates");

function App() {
  var [msg, setMsg] = React.useState("checking...");

  React.useEffect(function() {
    async function check() {
      try {
        var rv = Updates.runtimeVersion || "empty";
        var ch = Updates.channel || "default";
        var id = Updates.updateId || "none";
        var emb = Updates.isEmbeddedLaunch ? "embedded" : "not-embedded";
        var info = "rv=" + rv + " ch=" + ch + " id=" + id + " emb=" + emb;

        var result = await Updates.checkForUpdateAsync();
        if (result.isAvailable) {
          info += "\nUPDATE AVAILABLE! downloading...";
          await Updates.fetchUpdateAsync();
          info += "\ndownloaded. Restart app.";
          await Updates.reloadAsync();
        } else {
          info += "\nno update available";
        }
        setMsg(info);
      } catch(e) {
        setMsg("Error: " + e.message);
      }
    }
    check();
  }, []);

  return React.createElement(View, {style: {flex:1,backgroundColor:"#0f172a",alignItems:"center",justifyContent:"center"}},
    React.createElement(Text, {style: {fontSize:28,fontWeight:"800",color:"#e2e8f0"}}, "Yuzu GCA"),
    React.createElement(Text, {style: {fontSize:14,color:"#64748b",marginTop:8}}, "v0.1.0-dav-android-10"),
    React.createElement(Text, {style: {fontSize:10,color:"#3b82f6",marginTop:8,textAlign:"center"}}, msg)
  );
}

AppRegistry.registerComponent("main", function() { return App; });
