Skip to content
Repos

DevPlaceApp

C++ 1.4 KB33 lines Opens in site

Directory Raw Download

#pragma once
// Spec: INV-social 2 (BoxView), 1.5 (DevPlaceTextFieldStyle), 4 (CapsuleLabel), 7 (UserBadgeView).
#include <optional>
#include <string>

#include "ui/Palette.hpp"
#include "ui/Views.hpp"

namespace dp {

struct BoxStyle {
  enum class Corner { Small, Normal, Big };
  enum class Pad { None, Small, Normal, Big };
  std::optional<ui::Color> background;   // default BG_2
  std::optional<ui::Color> foreground;   // default FG_1
  std::optional<ui::Color> border;       // default FG_2
  float borderOpacity = 0.25f;
  float borderWidth = 1;
  Corner corner = Corner::Normal;
  Pad padding = Pad::Normal;
  static float cornerValue(Corner c) { return c == Corner::Small ? 10.0f : c == Corner::Normal ? 12.0f : 14.0f; }
  static float padValue(Pad p) { return p == Pad::None ? 0.0f : p == Pad::Small ? 10.0f : p == Pad::Normal ? 12.0f : 16.0f; }
};

// SwiftUI BoxView: content, padding, inset border, rounded background.
ui::ViewPtr BoxView(ui::ViewPtr content, const BoxStyle& style = {});
// `.textFieldStyle(.devPlace)`: BoxView(bg BG_1, borderOpacity 0.5, big corner, small padding).
ui::ViewPtr DevPlaceField(ui::ViewPtr field, std::optional<ui::Color> background = std::nullopt);
// Uppercased 12 pt medium label on a capsule.
ui::ViewPtr CapsuleLabel(const std::string& text, std::optional<ui::Color> foreground = std::nullopt,
                         std::optional<ui::Color> background = std::nullopt);

}  // namespace dp
40.7ms