package com.cooleshow.teacher.ui.mine;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.annotation.Nullable;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.cooleshow.base.router.RouterPath;
import com.cooleshow.base.ui.activity.BaseMVPActivity;
import com.cooleshow.base.utils.ToastUtil;
import com.cooleshow.base.utils.ToastUtils;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.contract.FeedBackContract;
import com.cooleshow.teacher.databinding.ActivityFeedbackBinding;
import com.cooleshow.teacher.presenter.mine.FeedBackPresenter;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import io.rong.imkit.utils.StatusBarUtil;

/**
 * 创建日期：2022/5/18 16:25
 *
 * @author Ryan
 * 类说明：
 */
@Route(path = RouterPath.MineCenter.MINE_FEEDBACK)
public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackBinding, FeedBackPresenter> implements FeedBackContract.FeedBackView, View.OnClickListener {
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.tv_submit:
                String content = viewBinding.etContent.getText().toString().trim();
                if (TextUtils.isEmpty(content)){
                    ToastUtil.getInstance().showShort("请输入您的反馈意见");
                    break;
                }
//                String mobileNo = viewBinding.etConnect.getText().toString().trim();
//                if (TextUtils.isEmpty(mobileNo)){
//                    ToastUtil.getInstance().showShort("请输入您的邮箱或手机号");
//                    break;
//                }
                Map<String, String> params = new HashMap<>();
                params.put("clientType", "Android");
                params.put("content", content);
                presenter.addSuggestion(params);
                break;
        }
    }
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtil.setStatusBarDarkTheme(this, true);
    }

    @Override
    protected void initView() {
        initMidTitleToolBar(viewBinding.toolbarInclude.toolbar, "意见反馈");
        viewBinding.tvSubmit.setOnClickListener(this);
    }

    @Override
    protected ActivityFeedbackBinding getLayoutView() {
        return ActivityFeedbackBinding.inflate(getLayoutInflater());
    }

    @Override
    protected FeedBackPresenter createPresenter() {
        return new FeedBackPresenter();
    }

    @Override
    public void addSuggestionSuccess(Object object) {
        ToastUtil.getInstance().showShort("提交成功");
        finish();
    }
}
