/*
 * Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#pragma once

#include <studio/context.hpp>
#include <studio/popup.hpp>

namespace studio {

class RenameFile: public Popup {

	private:
		enum class Stage {
			Closed,
			Opening,
			Open,
		};
		Stage m_stage{};
		ox::String m_oldPath;
		ox::String m_path;
		ox::IString<255> m_name;
		bool m_fileExists{};
		bool m_open{};

	public:
		ox::Signal<ox::Error(ox::StringViewCR src, ox::StringViewCR dst)> moveFile;

		RenameFile();

		ox::Error openPath(ox::StringParam path) noexcept;

		void open() noexcept override;

		void close() noexcept override;

		[[nodiscard]]
		bool isOpen() const noexcept override;

		void draw(Context &ctx) noexcept override;

};

}
