Skip to content
CrossFly is 100% open sourceFollow us on GitHub
CrossFlyCrossFly
Get started

This page was machine-translated from Portuguese and may contain errors. The Portuguese version is canonical.

Coming from SwiftUI

In SwiftUI the body is computed and the view invalidates itself when @State changes. In CrossFly you build once and mutate. Read the philosophy first.

Translation table

SwiftUI CrossFly
computed View / body UI built once in onShow()
@State / @Binding / @ObservedObject fields + repaint() (no automatic invalidation)
VStack / HStack / ZStack VerticalLayout / HorizontalLayout / RelativeLayout
Spacer() Gap / fractions (the framework’s Spacer was removed)
.padding() ingap in the style
List VirtualListView
Text Label
Button Button
NavigationStack / .sheet stack of Window / ActionSheet
.alert Alert
async / await / Task Thread + Component.onUI(...)
Color int 0xAARRGGBB

Target difference

SwiftUI runs on Apple only. CrossFly is one Java codebase that runs on iOS and Android, Desktop and Web — the same screen code on all of them (see platforms).

Before / after — form

// SwiftUI
struct LoginView: View {
   @State private var email = ""
   var body: some View {
      VStack {
         TextField("E-mail", text: $email)
         Button("Entrar") { entrar(email) }
      }
   }
}
// CrossFly
public class LoginScreen extends Window {
   @Override public void onShow() throws Exception {
      super.onShow();
      setLayout(new VerticalLayout());
      TextField email = new TextField().caption("E-mail");
      add(LAY_AUTO, email);
      Button entrar = new Button("Entrar");
      entrar.onAction(c -> entrar(email.getText()));   // reads the value on submit (no $binding)
      add(LAY_AUTO, entrar);
   }
}

No $binding: you read getText() when you need it (e.g., in onAction); there is no automatic field↔variable binding (see Text fields).

See also

Was this page helpful?