| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import 'package:flutter/cupertino.dart';
- import 'package:injectable/injectable.dart';
- import 'package:keyboard/base/base_controller.dart';
- import 'package:keyboard/data/repository/account_repository.dart';
- import 'package:get/get.dart';
- import '../../resource/string.gen.dart';
- import '../../utils/error_handler.dart';
- import '../../utils/toast_util.dart';
- @injectable
- class FeedbackController extends BaseController {
- final RxString _phone = ''.obs;
- final RxString _content = "".obs;
- get phone => _phone.value;
- get content => _content.value;
- final AccountRepository accountRepository;
- FeedbackController(this.accountRepository);
- onPhoneChanged(String phone) {
- _phone.value = phone;
- }
- onContentChanged(String content) {
- _content.value = content;
- }
- backClick() {
- debugPrint("backClick");
- Get.back();
- }
- submitClick() {
- if (_content.value.isEmpty) {
- ToastUtil.show(StringName.feedbackContentEmpty);
- return;
- }
- if (_phone.value.isEmpty) {
- ToastUtil.show(StringName.feedbackPhoneEmpty);
- return;
- }
- accountRepository
- .complaintSubmit(_phone.value, _content.value)
- .then((data) {
- ToastUtil.show(StringName.feedbackSubmitSuccess);
- Get.back();
- })
- .catchError((error) {
- ErrorHandler.toastError(error);
- });
- }
- }
|