import 'package:flutter/cupertino.dart';
import 'package:injectable/injectable.dart';
import 'package:keyboard/base/base_controller.dart';
import 'package:get/get.dart';
import 'package:keyboard/utils/atmob_log.dart';
import 'package:keyboard/utils/toast_util.dart';

@injectable
class ChangeNicknameController extends BaseController {
  final tag = "ChangeNicknameController";

  final RxString nickname = "".obs;

  ChangeNicknameController();

  TextEditingController textEditingController = TextEditingController();

  @override
  onInit() {
    super.onInit();
    final String? nickName = Get.arguments?["nickName"];
    if (nickName != null) {
      nickname.value = nickName;
      textEditingController.text = nickName;
    }
  }

  clickBack() {
    Get.back();
  }

  clickSave() {
    if (nickname.value.isEmpty) {
      ToastUtil.show("请输入昵称");
      return;
    }if (nickname.value.length > 5) {
      ToastUtil.show("昵称最多5个字~");
      return;
    }
    Get.back(result: nickname.value);
  }
}
