settingsColumn function

Column settingsColumn(
  1. TextEditingController pathController,
  2. TextEditingController startCmdController,
  3. TextEditingController userController,
  4. dynamic context,
  5. dynamic item,
  6. bool isSyncing,
  7. Function setState
)

Implementation

Column settingsColumn(
    TextEditingController pathController,
    TextEditingController startCmdController,
    TextEditingController userController,
    context,
    item,
    bool isSyncing,
    Function setState) {
  return Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      Padding(
        padding: const EdgeInsets.only(bottom: 8.0),
        child: Text('startcommand-text'.i18n()),
      ),
      Tooltip(
        message: 'startcommand-text'.i18n(),
        child: TextBox(
          controller: startCmdController,
          placeholder: 'e.g. /bin/bash',
        ),
      ),
      Padding(
        padding: const EdgeInsets.only(bottom: 8.0, top: 8.0),
        child: Text('startdirectorypath-text'.i18n()),
      ),
      Tooltip(
        message: 'startdirectorypath-text'.i18n(),
        child: TextBox(
          controller: pathController,
          placeholder: '/home/user/project',
        ),
      ),
      Padding(
        padding: const EdgeInsets.only(bottom: 8.0, top: 8.0),
        child: Text('startuser-text'.i18n()),
      ),
      Tooltip(
        message: 'wsldefaultuser-text'.i18n(),
        child: TextBox(
          controller: userController,
          placeholder: 'root',
        ),
      ),
      Padding(
        padding: const EdgeInsets.only(bottom: 8.0, top: 8.0),
        child: Text('emptyfieldsfordefault-text'.i18n()),
      ),
      const SizedBox(
        height: 8.0,
      ),
      wslSettings(item, setState),
      const SizedBox(
        height: 12.0,
      ),
      Sync().hasPath(item)
          ? MouseRegion(
              cursor: SystemMouseCursors.click,
              child: Tooltip(
                message: 'upload-text'.i18n(),
                child: Button(
                  style: ButtonStyle(
                      padding: ButtonState.all(const EdgeInsets.only(
                          left: 15.0, right: 15.0, top: 10.0, bottom: 10.0))),
                  child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('startstopserving-text'.i18n()),
                        const Icon(FluentIcons.upload),
                      ]),
                  onPressed: () {
                    plausible.event(name: "network_uploaded");
                    Sync sync = Sync.instance(item);
                    if (!isSyncing) {
                      isSyncing = true;
                      sync.startServer();
                      Notify.message('startedserving-text'.i18n([item]));
                    } else {
                      isSyncing = false;
                      sync.stopServer();
                      Notify.message('stoppedserving-text'.i18n([item]));
                    }
                  },
                ),
              ),
            )
          : Container(),
      const SizedBox(height: 8.0),
      Sync().hasPath(item)
          ? MouseRegion(
              cursor: SystemMouseCursors.click,
              child: Tooltip(
                message: 'download-text'.i18n(),
                child: Button(
                  style: ButtonStyle(
                      padding: ButtonState.all(const EdgeInsets.only(
                          left: 15.0, right: 15.0, top: 10.0, bottom: 10.0))),
                  child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text('downloadoverride-text'.i18n()),
                        const Icon(FluentIcons.download),
                      ]),
                  onPressed: () {
                    plausible.event(name: "network_downloaded");
                    dialog(
                        item: item,
                        title: 'syncfromserver-text'.i18n([distroLabel(item)]),
                        body: 'syncwarning-text'.i18n([item]),
                        submitText: 'yesoverride-text'.i18n(),
                        submitInput: false,
                        submitStyle: ButtonStyle(
                          backgroundColor: ButtonState.all(Colors.red),
                          foregroundColor: ButtonState.all(Colors.white),
                        ),
                        onSubmit: (inputText) {
                          Sync sync = Sync.instance(item);
                          sync.download();
                        });
                  },
                ),
              ),
            )
          : Container(),
      const SizedBox(height: 8.0),
      MouseRegion(
        cursor: SystemMouseCursors.click,
        child: Tooltip(
          message: 'move-text'.i18n(),
          child: Button(
            style: ButtonStyle(
                padding: ButtonState.all(const EdgeInsets.only(
                    left: 15.0, right: 15.0, top: 10.0, bottom: 10.0))),
            child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('move-text'.i18n()),
                  const Icon(FluentIcons.move),
                ]),
            onPressed: () async {
              dialog(
                  item: item,
                  title: '${'move-text'.i18n()} \'${distroLabel(item)}\'',
                  body: 'movebody-text'.i18n([distroLabel(item)]),
                  submitText: 'move-text'.i18n(),
                  submitStyle: ButtonStyle(
                    backgroundColor: ButtonState.all(Colors.red),
                    foregroundColor: ButtonState.all(Colors.white),
                  ),
                  submitInput: false,
                  onSubmit: (inputText) async {
                    Notify.message(
                        'moving-text'.i18n([distroLabel(item), inputText]),
                        loading: true);
                    await WSLApi().move(item, getInstancePath(item).path);
                    Notify.message(
                        'moved-text'.i18n([distroLabel(item), inputText]));
                  });
            },
          ),
        ),
      )
    ],
  );
}