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

#pragma once

#include <ox/std/string.hpp>

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

namespace studio {

class NewDir final: public Popup {
 	private:
		enum class Stage {
			Closed,
			Opening,
			Open,
		};
		Stage m_stage = Stage::Closed;
		bool m_open{};
		ox::String m_path;
		ox::IString<255> m_str;

	public:
		ox::Signal<ox::Error(ox::StringViewCR path)> newDir;

		NewDir() noexcept;

		void openPath(ox::StringViewCR path) noexcept;

		void open() noexcept override;

		void close() noexcept override;

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

		void draw(Context &ctx) noexcept override;

		[[nodiscard]]
		constexpr ox::CStringView value() const noexcept {
			return m_str;
		}

};

}
