/*
 * progress_dialog.h
 *
 *  Created on: 2021年10月30日
 *      Author: pengzc
 */

#ifndef JNI_CORE_POPUP_SERVICE_H_
#define JNI_CORE_POPUP_SERVICE_H_

#include <atomic>
#include <functional>
#include <thread>

enum class PopupType {
  Dialog,
  Progress,
};

class PopupService {
public:
  virtual ~PopupService();
  static PopupService* instance();

  typedef std::function<int (PopupService* dialog)> Task;

  static void Show(Task task);
  static void Dialog(const std::string& text);

  void SetMessage(const std::string& msg);
  void Animation(bool visible);

  static bool busy();
private:
  PopupService();

  static void Show(Task task, PopupType type);
  void InternalShow(const Task& func, PopupType type);

  friend void NavibarDialog1ClickOk();
private:
  std::atomic<bool> busy_;
};

#endif /* JNI_CORE_POPUP_SERVICE_H_ */
