WeddingPlatform.Web 1.0.0.0
지도, 갤러리, 방명록, 계좌 안내와 배경음악을 링크 하나에 담는 무료 모바일 청첩장 서비스입니다.
로딩중...
검색중...
일치하는것 없음
InvitationDesign.cs
이 파일의 문서화 페이지로 가기
1using System.Text.Json.Serialization;
2using Wedding.Common;
3
5
14public sealed class DesignSettings
15{
24 public string ThemeKey { get; set; } = "rose";
33 public WeddingLayoutMode LayoutMode { get; set; } = WeddingLayoutMode.WebPage;
42 public HeroPlacement HeroPlacement { get; set; } = new();
51 public WeddingFloatingPosition MusicButtonPlacement { get; set; } = new();
60 public List<StoryChapter> StoryChapters { get; set; } = WeddingStoryChapterDefaults.Create();
69 public List<string> SectionOrder { get; set; } =
70 WeddingSectionOrderCatalog.InvitationRecommendedOrder.ToList();
79 public Dictionary<string, bool> SectionVisibility { get; set; } = new();
80}
81
90public sealed class HeroPlacement
91{
100 public HeroPanelPlacement InviteTop { get; set; } = new("top", "center", "top", "center");
109 public HeroPanelPlacement InviteBottom { get; set; } = new("bottom", "center", "bottom", "center");
118 public HeroPanelPlacement ThankYou { get; set; } = new("top", "center", "top", "center");
119}
120
129public sealed class HeroPanelPlacement
130{
140 {
141 }
142
183 public HeroPanelPlacement(string desktopVertical, string desktopHorizontal, string mobileVertical, string mobileHorizontal)
184 {
185 DesktopVertical = desktopVertical;
186 DesktopHorizontal = desktopHorizontal;
187 MobileVertical = mobileVertical;
188 MobileHorizontal = mobileHorizontal;
189 }
190
199 public string DesktopVertical { get; set; } = "top";
208 public string DesktopHorizontal { get; set; } = "center";
217 public string MobileVertical { get; set; } = "top";
226 public string MobileHorizontal { get; set; } = "center";
235 public double? DesktopX { get; set; }
244 public double? DesktopY { get; set; }
253 public double? MobileX { get; set; }
262 public double? MobileY { get; set; }
263
272 public bool HasDesktopCustomPosition => DesktopX.HasValue && DesktopY.HasValue;
281 public bool HasMobileCustomPosition => MobileX.HasValue && MobileY.HasValue;
282}
283
292public static class InvitationDesignCatalog
293{
302 public static IReadOnlyList<WeddingThemeOption> Themes => WeddingThemeCatalog.Options;
303
312 public static IReadOnlyList<WeddingLayoutOption> Layouts => WeddingLayoutCatalog.Options;
313
338 public static WeddingLayoutOption GetLayout(WeddingLayoutMode mode) =>
339 WeddingLayoutCatalog.Instance.Find(mode) ?? WeddingLayoutCatalog.Options[0];
340
365 public static WeddingThemeOption GetTheme(string? key) =>
366 WeddingThemeCatalog.Instance.Find(key) ?? WeddingThemeCatalog.Options[0];
367
384 public static void Normalize(TenantConfig config)
385 {
386 config.DesignSettings ??= new DesignSettings();
387 config.DesignSettings.HeroPlacement ??= new HeroPlacement();
388 config.DesignSettings.HeroPlacement.InviteTop ??= new HeroPanelPlacement();
389 config.DesignSettings.HeroPlacement.InviteBottom ??= new HeroPanelPlacement();
390 config.DesignSettings.HeroPlacement.ThankYou ??= new HeroPanelPlacement();
391 config.DesignSettings.MusicButtonPlacement ??= new WeddingFloatingPosition();
392 config.DesignSettings.StoryChapters = WeddingStoryChapterDefaults.Normalize(config.DesignSettings.StoryChapters);
393 config.UnlockedLayoutModes ??= new();
394 config.UnlockedThemeKeys ??= new();
395
396 var themeKey = !string.IsNullOrWhiteSpace(config.DesignSettings.ThemeKey)
397 ? config.DesignSettings.ThemeKey
398 : config.ThemeName;
399 config.DesignSettings.ThemeKey = WeddingThemeCatalog.NormalizeKey(themeKey);
400 config.ThemeName = config.DesignSettings.ThemeKey;
401
402 config.DesignSettings.LayoutMode = ResolveLayoutMode(config.DesignSettings.LayoutMode, config.InvitationStyle);
403 config.InvitationStyle = ToLegacyLayoutKey(config.DesignSettings.LayoutMode);
404 config.DesignSettings.SectionOrder = WeddingSectionOrderCatalog.NormalizeInvitationOrder(
406 GetLayout(config.DesignSettings.LayoutMode).SupportedSections);
407 config.DesignSettings.SectionVisibility ??= new Dictionary<string, bool>();
408
414 }
415
448 public static WeddingLayoutMode ResolveLayoutMode(WeddingLayoutMode mode, string? legacyStyle)
449 {
450 if (mode != WeddingLayoutMode.Unknown && WeddingLayoutCatalog.Instance.Exists(mode))
451 {
452 return mode;
453 }
454
455 return FromLegacyLayoutKey(legacyStyle);
456 }
457
482 public static WeddingLayoutMode FromLegacyLayoutKey(string? key) =>
483 WeddingLayoutCatalog.FromLegacyKey(key);
484
509 public static string ToLegacyLayoutKey(WeddingLayoutMode mode) =>
510 WeddingLayoutCatalog.ToLegacyKey(mode);
511
528 private static void SyncPlacementFromLegacy(TenantConfig config)
529 {
530 var placement = config.DesignSettings.HeroPlacement;
531 placement.InviteTop.DesktopVertical = FirstNonBlank(placement.InviteTop.DesktopVertical, config.InviteHeroTopVerticalDesktop);
532 placement.InviteTop.DesktopHorizontal = FirstNonBlank(placement.InviteTop.DesktopHorizontal, config.InviteHeroTopHorizontalDesktop);
533 placement.InviteTop.MobileVertical = FirstNonBlank(placement.InviteTop.MobileVertical, config.InviteHeroTopVerticalMobile);
534 placement.InviteTop.MobileHorizontal = FirstNonBlank(placement.InviteTop.MobileHorizontal, config.InviteHeroTopHorizontalMobile);
535
536 placement.InviteBottom.DesktopVertical = FirstNonBlank(placement.InviteBottom.DesktopVertical, config.InviteHeroBottomVerticalDesktop);
537 placement.InviteBottom.DesktopHorizontal = FirstNonBlank(placement.InviteBottom.DesktopHorizontal, config.InviteHeroBottomHorizontalDesktop);
538 placement.InviteBottom.MobileVertical = FirstNonBlank(placement.InviteBottom.MobileVertical, config.InviteHeroBottomVerticalMobile);
539 placement.InviteBottom.MobileHorizontal = FirstNonBlank(placement.InviteBottom.MobileHorizontal, config.InviteHeroBottomHorizontalMobile);
540
541 placement.ThankYou.DesktopVertical = FirstNonBlank(placement.ThankYou.DesktopVertical, config.HeroPanelVerticalDesktop);
542 placement.ThankYou.DesktopHorizontal = FirstNonBlank(placement.ThankYou.DesktopHorizontal, config.HeroPanelHorizontalDesktop);
543 placement.ThankYou.MobileVertical = FirstNonBlank(placement.ThankYou.MobileVertical, config.HeroPanelVerticalMobile);
544 placement.ThankYou.MobileHorizontal = FirstNonBlank(placement.ThankYou.MobileHorizontal, config.HeroPanelHorizontalMobile);
545 }
546
563 private static void SyncLegacyFromPlacement(TenantConfig config)
564 {
565 var placement = config.DesignSettings.HeroPlacement;
566 config.InviteHeroTopVerticalDesktop = placement.InviteTop.DesktopVertical;
567 config.InviteHeroTopHorizontalDesktop = placement.InviteTop.DesktopHorizontal;
568 config.InviteHeroTopVerticalMobile = placement.InviteTop.MobileVertical;
569 config.InviteHeroTopHorizontalMobile = placement.InviteTop.MobileHorizontal;
570 config.InviteHeroBottomVerticalDesktop = placement.InviteBottom.DesktopVertical;
571 config.InviteHeroBottomHorizontalDesktop = placement.InviteBottom.DesktopHorizontal;
572 config.InviteHeroBottomVerticalMobile = placement.InviteBottom.MobileVertical;
573 config.InviteHeroBottomHorizontalMobile = placement.InviteBottom.MobileHorizontal;
574 config.HeroPanelVerticalDesktop = placement.ThankYou.DesktopVertical;
575 config.HeroPanelHorizontalDesktop = placement.ThankYou.DesktopHorizontal;
576 config.HeroPanelVerticalMobile = placement.ThankYou.MobileVertical;
577 config.HeroPanelHorizontalMobile = placement.ThankYou.MobileHorizontal;
578 }
579
604 private static void NormalizePlacement(HeroPanelPlacement placement, string verticalFallback)
605 {
606 placement.DesktopVertical = NormalizeOption(placement.DesktopVertical, ["top", "middle", "bottom"], verticalFallback);
607 placement.DesktopHorizontal = NormalizeOption(placement.DesktopHorizontal, ["left", "center", "right"], "center");
608 placement.MobileVertical = NormalizeOption(placement.MobileVertical, ["top", "middle", "bottom"], verticalFallback);
609 placement.MobileHorizontal = NormalizeOption(placement.MobileHorizontal, ["left", "center", "right"], "center");
610 }
611
644 private static string FirstNonBlank(string? preferred, string fallback) =>
645 string.IsNullOrWhiteSpace(preferred) ? fallback : preferred;
646
687 private static string NormalizeOption(string? value, string[] allowed, string fallback)
688 {
689 var normalized = value?.Trim().ToLowerInvariant();
690 return !string.IsNullOrWhiteSpace(normalized) && allowed.Contains(normalized) ? normalized : fallback;
691 }
692}
WeddingFloatingPosition MusicButtonPlacement
Dictionary< string, bool > SectionVisibility
HeroPanelPlacement(string desktopVertical, string desktopHorizontal, string mobileVertical, string mobileHorizontal)
static void NormalizePlacement(HeroPanelPlacement placement, string verticalFallback)
static IReadOnlyList< WeddingThemeOption > Themes
static WeddingLayoutMode FromLegacyLayoutKey(string? key)
static string ToLegacyLayoutKey(WeddingLayoutMode mode)
static string FirstNonBlank(string? preferred, string fallback)
static WeddingThemeOption GetTheme(string? key)
static WeddingLayoutMode ResolveLayoutMode(WeddingLayoutMode mode, string? legacyStyle)
static void Normalize(TenantConfig config)
static void SyncLegacyFromPlacement(TenantConfig config)
static IReadOnlyList< WeddingLayoutOption > Layouts
static string NormalizeOption(string? value, string[] allowed, string fallback)
static WeddingLayoutOption GetLayout(WeddingLayoutMode mode)
static void SyncPlacementFromLegacy(TenantConfig config)