package com.datarecovery.master.module.feedback;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.atmob.app.lib.base.BaseActivity;
import com.datarecovery.master.databinding.ActivityUserFeedbackBinding;
import com.gyf.immersionbar.ImmersionBar;

import dagger.hilt.android.AndroidEntryPoint;


/**
 * 用户反馈
 */
@AndroidEntryPoint
public class UserFeedbackActivity extends BaseActivity<ActivityUserFeedbackBinding> {


    private UserFeedbackViewModel userFeedbackViewModel;


    public static void start(Context context) {
        Intent intent = new Intent(context, UserFeedbackActivity.class);
        if (!(context instanceof Activity)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        context.startActivity(intent);
    }


    @Override
    protected boolean shouldImmersion() {
        return true;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        initObserver();
    }

    private void initView() {
        addTopStatusBarHeight(binding.toolBar);
        binding.toolBar.setNavigationOnClickListener(v -> onBackPressed());
    }

    private void initObserver() {
        userFeedbackViewModel.getFinishEvent().observe(this, o -> onBackPressed());
    }

    @Override
    protected void configImmersion(@NonNull ImmersionBar immersionBar) {
        immersionBar.statusBarDarkFont(true);
    }


    @Override
    protected void initViewModel() {
        super.initViewModel();
        userFeedbackViewModel = getViewModelProvider().get(UserFeedbackViewModel.class);
        binding.setFeedbackViewModel(userFeedbackViewModel);
    }
}
