Skip to content
Repos

DevPlaceApp

Markdown 49.5 KB640 lines Opens in site

Directory Raw Download

Inventory: Posts, Comments, Reactions, Votes, Polls, Reports

Source of truth: DevPlaceIOS/DevPlaceIOS/UI/ (abbreviated UI/), DevPlaceIOS/DevPlaceIOS/Model Updates/ (MU/), DevPlaceIOS/DevPlaceIOS/AppState/ (AS/), DevPlaceIOS/DevPlaceSwiftSDK/Sources/DevPlaceSwiftSDK/ (SDK/). Citations are file:line. Where a value is defined outside the requested scope it is marked (ext) and cited. This document states what the iOS app does today; unknown token values are listed under Gaps.

0. Conventions and shared pieces

0.1 Reading SwiftUI terms

  • VStack(alignment:, spacing:): vertical box, children stacked top to bottom, spacing px between children (points, 1 pt = 1 logical px). Default spacing when omitted is system-defined (about 8 pt); this doc always states explicit values where code has them.
  • .padding() with no argument = 16 pt on all four sides (system default on iPhone). .padding(.horizontal) = 16 pt left+right. .padding(.top) = 16 pt top.
  • .frame(maxWidth: .infinity, alignment: .leading) = fill available width, content left aligned.
  • LazyVStack = vertical stack that only builds visible children.
  • Spacer() = flexible gap; Spacer(minLength: 0) = flexible gap that may collapse to 0.
  • Font names: .title = 28 pt regular, .title3 = 20 pt, .headline = 17 pt semibold, .subheadline = 15 pt, .footnote = 13 pt, .caption = 12 pt (iOS default Dynamic Type "Large" sizes). .font(.system(size: N * scale)) = N pt scaled by Dynamic Type @ScaledMetric (scale = 1.0 at default text size).
  • Color tokens (asset names, values not in scope, see Gaps): BG_0, BG_1, BG_2, FG_1 (primary text), FG_2 (secondary text), accentColor (app accent), agStart/agEnd (accent gradient), AFG (text on accent gradient), plus system .red, .gray.
  • .opacity(x) on a token = same RGB at alpha x.

0.2 Shared helpers (ext, needed to reproduce pixels)

  • AlertMessage (UI/Util/AlertMessage.swift:6-90): fields isPresented, title, message, buttonText. .presentedError(error) (22-69) gives title "Error", button "OK" (19), message derived from error: CancellationError shows nothing (26-27, 34-35); DevPlaceError.message; API error with status: if apiError.isSpecific message only, else "(<status>) <message>" (43-47); otherwise localizedDescription. .alert(_:) modifier (77-90): standard iOS alert, one button of role cancel with buttonText.
  • screenStyle(bgColor, fgColor) (UI/Style/Screen/ScreenStyleModifier.swift:3-28): fills the whole screen (ignores safe area) with bgColor, sets foreground FG_1.
  • BoxView (UI/Components/BoxView.swift:3-55): content with padding (default 12; small 10, big 16), then RoundedRectangle border (strokeBorder width 1, color FG_2 at opacity 0.25) overlaid, and the same rounded rect filled behind (default fill BG_2, default corner radius 12; small 10, big 14).
  • Text field style .devPlace (UI/Style/TextFieldStyles/DevPlaceTextFieldStyle.swift:68-81): BoxView(backgroundColor BG_1, borderOpacity 0.5, cornerSize big=14, paddingSize small=10) around the field.
  • Button style .form (UI/Style/ButtonStyles/FormButtonStyle.swift:42-52): label fills width left aligned, tap area = whole rectangle, color FG_1, gray while pressed.
  • Button style .accentGradient(shape:) (UI/Style/ButtonStyles/AccentGradientButtonStyle.swift:3-40): label semibold, padding 16 horizontal / 12 vertical, background = shape (circle, or rounded rect radius 14) filled with linear gradient agStart to agEnd from top-left to bottom-right, opacity 0.7 while pressed, drop shadow color accentColor at 0.5 alpha radius 5 (no offset), label color AFG, scale 0.95 while pressed.
  • CapsuleLabel(text) (UI/Components/CapsuleLabel.swift:3-19): text uppercased, system 12 pt medium, color FG_1, padding 8 h / 3 v (scaled), Capsule fill gray at 0.5 alpha.
  • RelativeTimeLabel(date) (UI/Components/RelativeTimeLabel.swift:3-13): Text(date, format: .relative(presentation: .named, unitsStyle: .narrow)) (iOS locale narrow relative, e.g. "2h ago"/"yesterday" style), system 12 pt, color FG_2.
  • UserAvatarView(user) (UI/Components/UserAvatarView.swift): avatar plus user.username (semibold) and "Level \(user.level)" (.caption); not detailed here.
  • DevPlaceTextEditor (UI/Components/DevPlaceTextEditor.swift): multi-line editor with placeholder (FG_2 at 0.5 alpha, padding v 8 / h 5, lines 108-111), inner padding h 5 / v 2 (124-125), 1.5 pt round-cap stroke FG_2 at 0.7 (130), padded 10/10 (186-187). Params used: placeholder, initialLineCount, initialHeight, animatesHeightChanges, backgroundColor, selection.
  • AttachmentUploaderView, AttachmentViewer, MentionSuggestionsView, MentionListHeightKey, EmojiPicker, VFlowStack, ProfileView, selectableTextPopover(_:): external, referenced below by name only.
  • TextCharacterCounter.numberOfCharacters(text) = text.utf16.count (UI/../Util/TextCharacterCounter.swift:1-5, DevPlaceIOS/DevPlaceIOS/Util). So an emoji with ZWJ counts as several. Mirrors web app counting; backend counts differently (comment in file line 3).
  • Limits DevPlaceConstants (SDK/DevPlaceConstants.swift:4-12): post title max 500, post content min 10 / max 125000, comment min 3 / max 125000, report detail max 2000, poll options max 6, attachments max 10 (maxAttachmentsCount), DM max 2000.
  • Date formats, API: all requests via DevPlaceApi wrappers (SDK/DevPlaceSwiftSDK.swift); POST bodies are JSON.

0.3 API endpoint table used by this area (SDK/DevPlaceSwiftSDK.swift)

| Operation | Method path | Body / params | Line | |---|---|---|---| | feed | GET feed | optional tab, topic, search, before (ISO-8601 date) | 127-139 | | post detail | GET posts/<slug> | none | 146-150 | | create post | POST posts/create | title?, topic, content, attachment_uids[], poll_question?, poll_options[], project_uid? | 152-183 | | edit post | POST posts/edit/<slug> | title, topic, content, project_uid (all strings, empty string when none) | 185-208 | | delete post | POST posts/delete/<slug> | none | 210-213 | | create comment | POST comments/create | target_type, target_uid, content, parent_uid?, attachment_uids[] | 217-235 | | edit comment | POST comments/edit/<uid> | content | 237-245 | | delete comment | POST comments/delete/<uid> | none | 247-250 | | vote | POST votes/<targetType>/<targetId> | {"value": 1|-1|0} | 416-423 | | poll vote | POST polls/<pollId>/vote | {"option_uid": id} | 430-437 | | react | POST reactions/<targetType>/<targetId> | {"emoji": e} | 444-451 | | report reasons | GET reports/reasons (no auth) | none; response reasons[] | 469-473 | | report | POST reports/<targetType>/<targetId> | {"reason": key, "detail": text?} | 479-487 | | delete attachment | DELETE uploads/delete/<uid> | none | 614-616 | | profile (projects list) | GET profile (own, when username nil) | none | 327-334 | targetType raw values: post, comment (SDK/Models/TypedStrings/TargetType.swift:2-3). Vote values: up=1, down=-1, none=0 (SDK/Models/TypedNumbers/Vote.swift:1-12). Toggle semantics (SDK comments 408-415, 424-429, 439-443): vote, poll vote and react endpoints all TOGGLE. Sending the value you already hold removes it. To clear an up-vote send up again, not 0. Sending the opposite replaces. Reactions are multi-select per target. Poll choice is single per poll.


1. Screens/Feed

Files: UI/Screens/Feed/FeedView.swift (FeedView.swift), UI/Screens/Feed/FeedView+ViewModel.swift (FeedVM.swift).

1.1 Visible strings

String Where Cite
"Posts" navigation title (inline display mode) FeedView.swift:55-56
"New post" accessibility label of the + button (icon only, not drawn as text) FeedView.swift:129-130
(alert) title "Error", button "OK", message from error feed errors FeedVM.swift:9,23,35 via AlertMessage

1.2 Layout tree

NavigationStack (provided by caller; Preview line 142)
  screen background BG_2 full bleed, foreground FG_1   (FeedView.swift:54)
  title "Posts" inline                                 (55-56)
  ScrollViewReader > ScrollView (vertical)             (83-84)
    LazyVStack (default spacing, alignment center)     (85)
      ForEach(feed.posts, id: post.id) FeedPostView    (86-98)   [section 3.1]
      if feed.nextCursor != nil:                       (99)
        ProgressView (spinner)                          (100)
          .padding() 16 all sides, .frame(maxWidth: .infinity)  (101-102)
          onAppear -> loadMore                           (103-107)
    .frame(maxWidth: .infinity)                        (110)
  overlay bottomTrailing (not composing only):         (124-136)
    Button(label: Label("New post", systemImage "plus") icon only)
      buttonStyle accentGradient(shape: circle)         (132)
      .padding() 16 around the button (distance from screen edge)  (133)
      transition: scale + opacity                       (134)

Notes:

  • LazyVStack has default spacing; FeedPostView draws its own 1 pt separator lines (section 3.1) so posts are visually divided by hairlines.
  • FAB size = icon (default system plus, body-size ~17 pt) + padding 16 h / 12 v (AccentGradientButtonStyle:14-15) clipped to a circle; because h and v padding differ the circle background fits the larger (width) dimension; reproduce as circle of diameter = icon width + 32 (height 12+12+icon, circle uses the larger side centered).

1.3 States

  • Loading first page: no spinner at screen level. feed is held in AppState.shared.feed (nil until loaded); with nil the list is empty (posts ?? [], line 86). The initial load is triggered elsewhere (ext, app shell); ViewModel.load() exists (FeedVM.swift:17-23) and is not called inside FeedView.
  • Empty feed: no empty-state view; blank screen with only the FAB.
  • Pagination: when nextCursor != nil a spinner row is the last item; its onAppear calls loadMore() (FeedView.swift:99-108). loadMore guards isLoadingMore (FeedVM.swift:38), sets flag, always resets in defer (39-40). On error alert (44-46).
  • Pull to refresh: .refreshable { await viewModel.refresh() } (FeedView.swift:58-60). refresh() calls api.feed() and, only on success, publishes the new feed 300 ms later (FeedVM.swift:25-35: Task.sleep(.milliseconds(300)) then AppState.shared.feed = newFeed). Error: alert.
  • Tab re-select: reselectSignal Bool changes (onChange, FeedView.swift:61-67): if scroll is at top (isAtTop), calls refresh(). Else nothing (parent handles scroll-to-top, ext).
  • isAtTop computed by onScrollGeometryChange: contentOffset.y <= contentInsets.top (112-116).
  • Composing mode: isComposing = activeReplyTargetId != nil || editingCommentId != nil (36-38). While composing the FAB is hidden (125) with scale+opacity transition.
  • Mention list height: preference MentionListHeightKey stored in state; when it changes the scroll view scrolls the composer anchor (CommentEditorView.scrollAnchorName = "commentComposerAnchor") to bottom (117-122).

1.4 Actions

Action Behavior Cite
Tap FAB present full-screen cover with NavigationStack { CreatePostView(mode: .create) } FeedView.swift:126-128, 72-79
Tap a post (or a comment inside it) selectedPost = PostDestination(slug, scrollToCommentId); push PostView(slug:, scrollToCommentId:) via navigationDestination(item:) with .id(destination) 68-71, 90-92
Pull down refresh as above 58
Scroll to end load more 103-107

Quote composer environment: QuoteComposer(isActive: isComposing, insert: insertQuote) (50-53). insertQuote: if editing a comment, store in pendingEditQuote (consumed by the edit editor); else if replying, append to AppSettingsStore.shared.draftReplyMessage (40-46).

1.5 AppState feed operations (AS/AppState.swift)

  • loadFeed(api): AppState.shared.feed = try await api.feed(); then loadUnreadCounts (AppState.swift:30-33 region in 11-14 of the printed slice; see file lines 30-33). Used after every mutation (create/delete/edit comment, delete post, edit post).
  • loadMoreFeed(api) (AppState.swift:59-81): requires feed and nextCursor; calls api.feed(before: cursor); filters out posts whose id already exists (dedup, logs duplicates); appends new posts; takes all metadata (tab, topic, search, nextCursor, counts, topAuthors) from the new page.

2. Screens/Post (post detail)

Files: UI/Screens/Post/PostView.swift (PostView.swift), UI/Screens/Post/PostView+ViewModel.swift (PostVM.swift).

2.1 Visible strings

String Where Cite
title = post title, fallback "Post" nav title (inline) PostVM.swift:21-23; PostView.swift:65-66 (printed 258-259)
"Reload" accessibility label of toolbar icon arrow.clockwise PostView.swift:529 printed -> 336
"Comments" section header PostView.swift:262
"Comment" (icon bubble.left) bottom comment button PostView.swift:319
"Write a comment…" placeholder of bottom editor PostView.swift:305
(post-level reply editor uses default placeholder) "Write a reply…" CommentEditorView.swift:8
Error alert all failures PostVM

Line numbers for PostView.swift below are exact file lines (printed line minus 193 offset applied).

2.2 Layout tree

screenStyle(bg BG_1)                                         PostView.swift:64
navigation title inline; trailing toolbar item = reload      65-72
content():
  if postDetail == nil: ProgressView() .frame(maxWidth/maxHeight .infinity)   112-114
  else ScrollViewReader > ScrollView
    VStack(spacing 0)                                          94
      postBody(detail)                                         96, 186-257
      commentsSection(detail)                                   98, 259-298
      bottomCommentSection(detail)                              100, 300-327

postBody (lines 186-257):

VStack(alignment .leading, spacing 8)
  PostHeaderView(author, date: post.createdAt, commentCount)   (linksToProfile default true)
  PostContentView(topic, title, content)
  if poll: PollView(poll)
  ForEach attachments: AttachmentViewer(attachment)             (ALL attachments)
  PostFooterView(targetId, authorId, starCount, currentVote, reactions,
                 onReact, onReply, isReplying: activeReply == .post,
                 onEdit/onDelete only if post.userId is current user)
  if activeReply == .post: CommentEditorView(initialLineCount 3, focusOnAppear true, ...) transition opacity
.frame(maxWidth .infinity, alignment .leading)
.padding()  (16 all)
.foregroundStyle(FG_1)
.background(BG_1)
.contentShape(Rectangle)
.onTapGesture(count 2)

commentsSection (259-298), only when comments non empty:

VStack(alignment .leading, spacing 8)
  Text("Comments") font .title3 (20 pt), weight semibold, .padding(.horizontal) 16, .padding(.top) 16
  CommentsView(comments, showsDividers: true, ...)   [section 7]
.frame(maxWidth .infinity, alignment .leading)

bottomCommentSection (300-327):

VStack(alignment .leading, spacing 8)
  if activeReply == .bottom:
     CommentEditorView(placeholder "Write a comment…", initialLineCount 3, focusOnAppear, ...) transition opacity
  else:
     Button(Label("Comment", systemImage "bubble.left")) buttonStyle .form, transition opacity
.frame(maxWidth .infinity, alignment .leading)
.padding() 16

Toolbar (reload, lines 329-340): if isReloading shows ProgressView(), else Button with Label "Reload" arrow.clockwise icon only; action reload().

2.3 States

  • Loading: centered spinner until postDetail set (.task { await viewModel.load() }, lines 82-84). Error on load: alert; screen stays on spinner.
  • Reloading: toolbar spinner; reload() guarded by isReloading (PostVM.swift:74-76).
  • Empty comments: Comments section hidden; bottom "Comment" button still shown.
  • No pagination in post detail.
  • Deep link to comment: scrollToCommentId -> on appear, after 50 ms, withAnimation { proxy.scrollTo(id, anchor: .top) } (PostView.swift:108-110, 118-126). The id is the comment's id = "comment:" + data.id (SDK/Models/Response/Comment.swift:4).
  • Mention list height change re-scrolls the composer anchor to bottom (102-107).
  • Reply anchor enum: .post, .comment(id), .bottom (lines 31-35). Only one composer at a time. Animation for composer in/out: .smooth(duration: 0.28) (line 37).
  • On disappear: unsubmitted reply attachments are deleted (85-87).

2.4 Actions and API

Action Behavior Cite
Double tap post area if own post: open edit cover; else upvoteForeignPost() PostView.swift:250-256
Footer reply icon beginReply(.post): delete pending attachments, animate activeReply = .post 129-134
Bottom "Comment" button beginReply(.bottom) 316-318
Cancel reply delete unsubmitted attachments; animate activeReply = nil 136-141
Submit post reply clear attachments, close composer, then submitComment(.post, post.id, parentId nil); on success clear draftReplyMessage 152-163
Submit comment reply submitComment(targetType from comment.data.targetType (fallback .post), targetId comment.data.targetId, parentId comment.data.id) 165-177
Edit post (footer pencil or double tap own) full-screen NavigationStack { CreatePostView(mode .edit(editablePost)) }; on complete reload() 73-81
Delete post confirmation (see 3.3), then deletePost(); on success dismiss() (pop) 411-419
React to post reactToPost(emoji) 403-405
Reload reload() 334

ViewModel (PostVM.swift):

  • load()/reload() (65-82): api.postDetail(slug); errors -> alert.
  • deletePost() (84-93): api.deletePost(slug) then AppState.loadFeed; returns true/false.
  • deleteComment (95-103), editComment (105-113), submitComment (115-125): API call, then re-fetch postDetail, then loadFeed. No optimistic update; errors -> alert. submitComment returns bool to clear draft.
  • deleteUnsubmittedAttachments (127-135): DELETE each; failures only logged.
  • upvoteForeignPost (137-152): not own; performVoteToggle(.post, id, currentVote); apply closure sets postDetail = detail.with(myVote:, starCount: starCount + newVote.value - myVote.value) and updatePostVoteInFeed.
  • doubleTapComment (154-169): not own comment; performVoteToggle(.comment ...); applies comments.updatingVote and updateCommentVoteInFeed.
  • reactToPost (171-183), reactToComment (185-197): performReactionToggle with local toggle (section 12).
  • mentionParticipants (25-48): authors of post and all nested comments (depth first), excluding current user, de-duplicated by id, as UserSearch.Result(id, username, avatarSeed).
  • editablePost (50-63): builds a Post from detail so the edit screen can be reused.

2.5 Markdown

Post body and titles go through PostContentView (section 3.3).


3. Components/Post

Files: UI/Components/Post/{FeedPostView, PostContentView, PostFooterView, PostHeaderView}.swift.

3.1 FeedPostView (feed card)

Strings: none own. Delete confirmation from footer (3.4). Layout (FeedPostView.swift:54-152):

VStack(alignment .leading, spacing 0)
  hLine()  .padding(.bottom 8)                       56-57
  VStack(alignment .leading, spacing 8)  .padding(.horizontal) 16      59-105
    PostHeaderView(author, date, linksToProfile false, commentCount)    60
    PostContentView(topic, title, content)                              62
    if poll: PollView(poll)                                             64-66
    if settings.showFeedAttachments and first attachment: AttachmentViewer(first)   68-70
    PostFooterView(starCount: post.data.stars, ...)                      72-89
    if replying to this post: CommentEditorView(initialLineCount 3, focusOnAppear)  91-103  transition opacity
  if settings.showFeedComments:                                          107-133
    CommentsView(comments: post.recentComments, baseIndentationLevel 1, linksToProfile false,
                 maxAttachments: showFeedAttachments ? 1 : 0, showsDividers true, showsLeadingDivider true)
    .padding(.top 8)
  hLine() .padding(.top 8)                                              135-136
.foregroundStyle(FG_1)  .background(BG_1)  .contentShape(Rectangle)    138-142

hLine() (154-156) = Color.FG_2 height 1 at opacity 0.3, full width. Gestures (143-144): double tap and single tap, only when activeReplyTargetId == nil: double -> handleDoubleTapPost, single -> navigateToPost() (needs post.data.slug; calls onSelect(slug, scrollToCommentId)). Feed cards are separated by the two hairlines (top of each card and bottom), no gap. Settings gates: showFeedAttachments, showFeedComments from AppSettingsStore (ext). Actions and API (all mutate AppState.shared.feed only, no per-post detail):

Action Behavior Cite
Double tap own post open edit cover (CreatePostView(mode .edit(post)), onComplete reloads feed) 237-241, 145-151
Double tap other's post performVoteToggle(.post); new count stars + newVote.value - myVote.value; updatePostVoteInFeed 242-250
Double tap other's comment performVoteToggle(.comment) + updateCommentVoteInFeed 253-266
Tap comment navigate to post scrolling to comment id 113
Delete post api.deletePost(slug) then loadFeed; failure only logged (no alert) 268-276
Delete / edit / create comment API then loadFeed; failures only logged, no alert, composer already closed; create returns false on failure so draft kept 226-235, 286-302
React performReactionToggle + feed local toggle 304-324
Reply start/cancel same attachment cleanup logic as PostView, activeReplyTargetId binding set to post id or comment id, .smooth(0.28) 163-197

Mention participants (32-52) built from post author + recentComments flattened.

3.2 PostHeaderView (PostHeaderView.swift:4-46)

HStack(alignment .top)       (default spacing)
  avatar: if linksToProfile -> NavigationLink to ProfileView(username) wrapping UserAvatarView
          else UserAvatarView alone
  Spacer()
  VStack(alignment .trailing, spacing 4)
    RelativeTimeLabel(date)
    if commentCount > 0: HStack(spacing 4){ Image "text.bubble"; Text("\(count)") }
        font system 12 (scaled), color FG_2, accessibility label "\(count) comments"   (36-45)

Feed cards use linksToProfile: false (tapping avatar goes to the post). Comments pass no commentCount.

3.3 PostContentView (PostContentView.swift:6-31)

VStack(alignment .leading, spacing 8) .frame(maxWidth .infinity, alignment .leading)
  if topic: CapsuleLabel(text: topic)                    // uppercased
  if title: Text(LocalizedStringKey(title)) .lineSpacing(0) .font(.title) .selectableTextPopover(title)
  Markdown(content) .markdownTheme(.devPlace) .markdownSoftBreakMode(.lineBreak) .selectableTextPopover(content)

Markdown:

  • Title uses LocalizedStringKey, i.e. SwiftUI inline markdown only (bold, italic, strikethrough, inline code, links), single line style, no blocks.
  • Body uses MarkdownUI (GitHub flavored): headings, paragraphs, emphasis, strong, strikethrough, inline code, fenced code, blockquotes, lists, task lists, tables, images, links, thematic breaks. Soft line breaks (single newline) render as line breaks (.lineBreak).
  • Theme .devPlace (UI/Style/MarkdownTheme.swift:4-39): inline code monospaced, size 0.85 em, background BG_2. Blockquote: HStack(spacing 0) of a bar (RoundedRectangle radius 6, fill FG_2, width 0.2 em) then the text colored FG_2 with horizontal padding 1 em; fixedSize vertical. Code block: horizontal ScrollView, monospaced 0.85 em, line spacing 0.225 em, padding v 6 / h 10, background BG_2, corner radius 8, margins top 6 / bottom 16. Everything else default MarkdownUI theme (basic).
  • selectableTextPopover(text) (ext, UI/Components/SelectableTextPopover.swift:32-84): long-press popover with actions "Select first word", "Select all text", "Copy to clipboard", and (only when quoteComposer.isActive) "Insert as quote" which inserts "> " + selectedText + "\n\n" into the active composer (line 81).
  • Used by posts, comment bodies (topic nil, title nil), and (ext) messages.

3.4 PostFooterView (PostFooterView.swift:4-85)

HStack(spacing 12)
  VoteView(.post, targetId, count: starCount, currentVote)         [section 8]
  ReactionsBar(reactions, onReact)                                  [section 9]
  Spacer(minLength 0)
  HStack(spacing 24)
    if onReply and not isReplying: Button(Label "Reply to post" icon arrowshape.turn.up.left) plain, FG_1
    ReportButton(.post, targetId, authorId)                         [section 11]
    if onEdit: Button(Label "Edit post" icon pencil) plain, FG_1
    if onDelete: Button(Label "Delete post" icon trash) plain, FG_1

Icons are default size (body, ~17 pt) icon only; labels are accessibility text. Delete flow: confirmationDialog("Delete this post?", titleVisibility .visible) with buttons "Delete" (destructive, calls onDelete) and "Cancel" (cancel role) (75-84). The edit and delete buttons exist only for the author's own post (callers pass nil otherwise).


4. Screens/CreatePost (create and edit post)

Files: UI/Screens/CreatePost/CreatePostView.swift (CPV.swift), CreatePostView+ViewModel.swift (CPVM.swift). Presented as full-screen cover inside its own NavigationStack (from Feed, FeedPostView, PostView).

4.1 Strings

String Where Cite
"Create New Post" / "Edit Post" nav title (inline) CPV.swift:50
"Close" (icon xmark) top-left toolbar button 53-59
"Create" (icon paperplane.fill) top-right when creating 73
"Save" (icon checkmark) top-right when editing 71
"Topic" row label and picker label 101, 103
topic names: Random, Devlog, Showcase, Question, Rant, Fun, Politics (rawValue capitalized, order = allCases) picker items SDK/Models/TypedStrings/PostTopic.swift:1-13
"Title (optional)" title placeholder, FG_2 at 0.5 CPV.swift:118-119
"What's on your mind?" message placeholder 140
"Add Poll" / "Remove Poll" (icon chart.bar.yaxis) poll toggle 171-173
"Link to Project" project row label 191
"None" first project picker option 196
"Poll question", "Option N" (N = index+1), "Add option" in CreatePollView (section 10)

Toolbar icons: buttons are Label(title, systemImage); default toolbar label style on iPhone is icon only for Label in topBar items (icon displayed).

4.2 Layout (CPV.swift:82-204)

screenStyle(bg BG_2)
ScrollView
  VStack(alignment .leading, spacing 14) .frame(maxWidth .infinity, alignment .leading) .padding() 16
    topicArea:    HStack{ Text("Topic"); Picker(menu style default); Spacer() }
    titleArea:    VStack(.leading){ TextField (textFieldStyle .devPlace, placeholder);
                                    CharacterCounterView(title, max 500).padding(.horizontal 11) }
    messageArea:  VStack(.leading){ DevPlaceTextEditor(placeholder, initialLineCount 7);
                                    CharacterCounterView(message, min 10, max 125000).padding(.horizontal 11) }
    if not editing:
       attachmentsArea: AttachmentUploaderView(attachments)
       pollArea: VStack(.leading, spacing 10){ Button{ BoxView{ Label("Add Poll"/"Remove Poll") } };
                                              if poll added: CreatePollView(question, options) } .frame(maxWidth .infinity, .leading)
    projectArea: only if projects non empty:
       HStack{ Text("Link to Project"); Picker(selection selectedProjectId: String?, "None" + each project.title) }

Entire content .disabled(isLoading) (34). Tapping anywhere (onTapGesture) clears focus (35-37). Title field submit key moves focus to message (124-126).

4.3 States

  • Create mode starts with persisted drafts: title/message are loaded from AppSettingsStore.draftPostTitle/draftPostMessage and every keystroke writes back (CPVM.swift:19-33, 62-65). Draft is only persisted in create mode.
  • Edit mode prefill: topic (PostTopic(rawValue) fallback .random), title, content (70-73). Attachments and poll not editable (hidden section 88). Project link not prefilled (TODO line 79); editing sends project_uid = "" if none chosen (144).
  • Loading: submit sets isLoading; trailing toolbar shows ProgressView instead of button (CPV.swift:62-63); content disabled.
  • loadProjects() on appear: api.profile(username: nil).projects; failure only logged, project row stays hidden (CPVM.swift:96-102).
  • On disappear: all unsubmitted attachments deleted via deleteAttachment(uid) (CPV.swift:42-46; CPVM.swift:164-175). Note: after a successful submit attachments is cleared first so nothing is deleted.
  • Counters: red when out of range (see 6).

4.4 Validation (CPVM.swift:104-111)

canSubmit = title length <= 500 (utf16 count; empty allowed) AND message length in [10, 125000]. Button .disabled(!canSubmit) (CPV.swift:76). No poll validation client-side (empty poll options are sent as-is; backend decides). Poll min options 2 (addPoll pads to 2 empty strings, 83-90).

4.5 Submit (CPVM.swift:113-162)

  1. isLoading = true.
  2. cleanTitle = trimmed (whitespace and newlines) title, nil if empty.
  3. Create: POST posts/create with title, topic, content = message (not trimmed), attachment uids, poll_question/poll_options only if poll added (else nil and []), project_uid. Edit: requires post.data.slug else throws DevPlaceError.postNotEditable; POST posts/edit/<slug> with title = cleanTitle ?? "", topic, content, project_uid = selectedProjectId ?? "".
  4. try? loadFeed (errors ignored).
  5. Reset fields (title "", message "", attachments, poll, project) which also clears the stored drafts.
  6. dismiss.send() -> onComplete() callback then dismiss() (CPV.swift:38-41).
  7. On error: alert "Error" + message, screen stays.

5. Components/Comment

Files: UI/Components/Comment/{CommentView, CommentsView, CommentEditorView}.swift.

5.1 CommentsView (CommentsView.swift)

  • Flattens the tree depth first into rows with level = baseIndentationLevel + depth (75-88). Post detail base 0; feed base 1.
  • VStack(spacing 0) of CommentView per row (30-57). showsTopDivider = showsDividers && (index > 0 || showsLeadingDivider) (53). previousIndentationLevel passed for divider alignment (54).
  • Delete and edit callbacks are only given to a comment when isCurrentUser(comment.data.userId) (60-72); otherwise nil, which hides trash/pencil and disables double tap edit.

5.2 CommentView (CommentView.swift)

Constants: maxIndentationLevel 3, indentWidth 16, guide line opacity 0.3 (33-35). effectiveLevel = min(level, 3) (37-39). Strings: "Reply to comment" (186), "Edit comment" (197), "Delete comment" (229), "Delete this comment?" confirmation (235), buttons "Delete" and "Cancel" (239-242), edit placeholder "Edit your comment…" (164). Layout (53-148):

HStack(alignment .top, spacing 0)
  for level 1...effectiveLevel: guide line column  width 16, full row height (55-59)
      VerticalLine drawn at the RIGHT edge of the 16 pt column (x = maxX), stroke FG_2 at 0.3, width 1,
      dashed [3,3] only for the column at level == 3, solid otherwise (246-262)
  VStack(alignment .leading, spacing 0)
    if showsTopDivider: Divider() .padding(.leading, dividerLeadingPadding) .padding(.trailing 16)  (63-67)
        dividerLeadingPadding = 16 + (max(effLevel, prevEffLevel) - effLevel) * 16   (41-45)  [prevEffLevel defaults to effLevel]
    commentBody
.foregroundStyle(FG_1)

commentBody (75-148):

VStack(alignment .leading, spacing 8)
  PostHeaderView(author, date, linksToProfile)         (no comment count)
  if editing: CommentEditorView (edit)  transition opacity
  else: PostContentView(topic nil, title nil, content) (markdown, section 3.3), measures its height -> contentHeight   transition opacity
  ForEach displayedAttachments (attachments truncated to maxAttachments when set; feed: 1 or 0): AttachmentViewer
  HStack(spacing 12)
     VoteView(.comment, id, count: comment.voteCount (= up - down), currentVote)
     ReactionsBar(reactions, onReact or no-op)
     Spacer(minLength 0)
     if not editing: HStack(spacing 24) [transition opacity]
         reply icon (arrowshape.turn.up.left) if onReply and not replying
         ReportButton(.comment, id, authorId)
         edit icon (pencil) if canEdit
         trash icon if onDelete != nil
  if replying and not editing: CommentEditorView(initialLineCount 3, focusOnAppear, attachments...) transition opacity
.frame(maxWidth .infinity, alignment .leading) .padding(.horizontal) 16 .padding(.vertical 8)
.contentShape(Rectangle)

Gestures (146-159): double tap: ignored while editing or replying; if canEdit (own comment, onSubmitEdit != nil) begin edit, else onDoubleTap (vote up toggle). Single tap: if not editing and not replying, onSingleTap (feed: open post at this comment; post detail: none supplied). Edit flow: beginEditing sets editedText = comment.content, animates (.smooth(0.28)) isEditing = true and editingCommentId binding = comment id (208-214); cancel/submit -> endEditing (216-223); submit calls onSubmitEdit(content) (API edit, then reload) and ends editing immediately (no optimistic text change; shows old text until refetch). Edit editor initial height = measured content height (165). pendingEditQuote appended to editedText when it changes (175-179). Delete: confirmation dialog then onDelete.

5.3 CommentEditorView (CommentEditorView.swift:4-132)

Defaults: placeholder "Write a reply…" (8); key scrollAnchorName "commentComposerAnchor" (5); keyboardGap 4 (21). Layout (23-102):

VStack(alignment .leading, spacing 0)
  MentionSuggestionsView(text, caret, participants, onSelect: insertMention)   (ext)
  VStack(alignment .leading, spacing 8)
    DevPlaceTextEditor(text, selection, placeholder, initialLineCount, animatesHeightChanges true, initialHeight, backgroundColor BG_0) .focused
    HStack(alignment .top, spacing 12)
      CharacterCounterView(text, min 3, max 125000) .padding(.horizontal 11)
      Spacer(minLength 0)
      HStack(spacing 24) .padding(.horizontal 11)
         if attachments change callback present and attachments empty: AttachmentUploaderView(isSmall true)
         Cancel button: icon `xmark` (label "Cancel"), plain, color FG_2
         Submit button: icon `checkmark` (label "Submit"), plain, color accentColor, disabled when !canSubmit
    if attachments non empty: full AttachmentUploaderView below (85-90)
.padding(.bottom 4)
.id("commentComposerAnchor")
  • focusOnAppear: after 50 ms sets focus (95-101).
  • canSubmit: utf16 count >= 3 and <= 125000 (104-108).
  • Mentions: the active @token at the caret (MentionToken ext) is replaced by @username (adds trailing space unless the next char is whitespace) and the caret is placed after it (120-131).
  • Submit passes raw text (not trimmed).

6. Components/CharacterCounterView and QuoteComposer

6.1 CharacterCounterView (UI/Components/CharacterCounterView.swift:3-24)

  • Text: "<count>/<max>" where both numbers are formatted with the locale grouping (count.formatted(), e.g. "1,234/125,000").
  • Font: system 12 pt (scaled), monospaced; base color FG_2; the count part is FG_2 when valid else red; the "/max" part always FG_2.
  • Valid = (minCount nil or count >= min) and count <= max. Count = utf16 length. Note: a count below the min (e.g. 0 of min 10) is shown red.
  • Usage: post title (max 500, no min), post message (min 10, max 125000), comment editor (min 3, max 125000), report detail (max 2000, no min).

6.2 QuoteComposer (UI/Components/QuoteComposer.swift:3-17)

Environment value quoteComposer with isActive: Bool (default false) and insert: (String) -> Void (default no-op). Provided by FeedView (FeedView.swift:50-53), PostView (PostView.swift:60-63) and ConversationView (ext). Consumer: selectableTextPopover shows "Insert as quote" only when isActive, inserting "> <selected text>\n\n". Receivers: post/feed reply drafts append to draftReplyMessage; editing comment gets pendingEditQuote.


7. Components/Reaction

Files: UI/Components/Reaction/{ReactionChipStyle, ReactionView, ReactionsStack, ReactionsBar}.swift. All sizes multiplied by @ScaledMetric scale (Dynamic Type).

7.1 ReactionChipStyle (ReactionChipStyle.swift:3-33)

Padding h 10 / v 5 (scaled). Background Capsule filled: mine = accentColor at 0.15 alpha, else BG_2. Border (strokeBorder inside the capsule): mine = accentColor width 1.5; else FG_2 at 0.25 alpha width 1.

7.2 ReactionView (ReactionView.swift:3-22)

HStack(spacing 4*scale): emoji Text system 14; count Text system 14 weight medium, monospacedDigit, FG_1; then chip style with isMine.

7.3 ReactionsBar (ReactionsBar.swift:4-40)

HStack(spacing 6): ReactionsStack then add button: Image("face.smiling") system 15 (scaled), color FG_2, chip style (not mine), plain button style, accessibility "Add reaction". Tap opens .sheet with NavigationStack { EmojiPicker { emoji in onReact(emoji) } } (ext). The sheet is not auto dismissed here (EmojiPicker decides, ext).

7.4 ReactionsStack (ReactionsStack.swift:4-85)

  • Items: from reactions.counts (emoji -> count), isMine = reactions.mine.contains(emoji), sorted by count descending then emoji string ascending (16-24).
  • Hidden entirely when no items (27).
  • Layout ReactionRowLayout (87-177), a single row with truncation: measures every chip at its ideal size; if all chips (width sum + 6 spacing) fit the proposed width, shows all; else shows the longest prefix such that prefix + 6 + width("…" chip) <= available, followed by the "…" more chip. Hidden chips are placed at x = -100000 (off screen) and marked accessibility hidden. Chips are vertically centered to the max height. The visible count is published back to state (121-128) for accessibility.
  • "…" chip: Text("…") system 14 (scaled), FG_1, chip style, accessibility "Show all reactions"; tap sets isShowingAll, shown as a popover (presentationCompactAdaptation(.popover), i.e. stays a popover on iPhone): VFlowStack(alignment .leading, spacing 6) of all chips as buttons, .padding() 16, width 300 (61-76). Tapping a chip there calls onSelect(emoji) and closes the popover.
  • Tap a chip = toggle that emoji (onSelect).
  • Local update: see section 12 (toggling model).

8. Components/VoteView

Files: UI/Components/VoteView/VoteView.swift (VV.swift), VoteView+ViewModel.swift (VVM.swift).

Layout (VV.swift:47-74):

HStack(spacing 10)
  Button(down): Image(count state == .down ? "minus.circle.fill" : "minus.circle") system 15 (scaled)
       plain style; color accentColor when active else FG_2; disabled if not logged in
  Text("\(count)") system 14 (scaled), weight semibold, monospacedDigit (color inherited FG_1)
  Button(up): Image(.up ? "plus.circle.fill" : "plus.circle") same style

Behavior (VVM.swift):

  • userCanVote = AppState.isLoggedIn (18-20); buttons disabled when false.
  • voteUp/voteDown (36-46): ignored while isLoading. newVote = none if the same direction is already selected, else the tapped direction.
  • apply (48-67): optimistic. Saves previous vote and count; sets currentVote = newVote; count = previousCount + newVote.value - previousVote.value (so up to down changes by -2); calls syncToFeed(); then api.vote(targetType, targetId, vote: selectedVote) where selectedVote is the TAPPED direction (up or down) even when removing, relying on server toggle. On failure: revert vote and count, syncToFeed(), alert "Error" with message.
  • syncToFeed (69-78): post -> updatePostVoteInFeed(postId, vote, count); comment -> updateCommentVoteInFeed(commentId, vote); others ignored.
  • Props sync: when the parent passes a different count/currentVote, the view model is overwritten (VV.swift:39-44).
  • Comment count shown = votes.up - votes.down (SDK Comment.swift:14-16).
  • Alert: standard "Error"/"OK".

8.1 AppState+Vote and Model Updates (shared, see section 12 for the full list).


9. Components/PollView

Files: UI/Components/PollView/PollView.swift (PV.swift), PollView+ViewModel.swift (PVM.swift).

Strings: question text (server), option labels (server), "\(total) vote" / "\(total) votes" (singular only when total == 1, PV.swift:51), "\(pct)%" (77), alert "Error"/"OK". Layout (PV.swift:38-104):

BoxView (defaults: fill BG_2, radius 12, padding 12, border FG_2 0.25 / 1pt)
  VStack(alignment .leading, spacing 10)
    Text(question) font .headline, FG_1
    VStack(spacing 6)  // option rows
      per option: Button(plain) containing
        HStack(spacing 8)
          Text(label) weight semibold if selected else regular, FG_1, multiline left, frame maxWidth .infinity left
          if selected: Image("checkmark") font .footnote semibold, accentColor
          Text("\(pct)%") .subheadline, monospacedDigit, FG_2
        .padding(h 12, v 10)
        .background(alignment .leading): bar = Rectangle filled accentColor, width = rowWidth * pct / 100,
              opacity 0.3 if selected else 0.2         (GeometryReader, 84-91)
        .background(BG_1)   (behind the bar)
        .clipShape(RoundedRectangle radius 10)
        .overlay RoundedRectangle(radius 10).strokeBorder( selected: accentColor 1.5pt ; else FG_2 at 0.25, 1pt )
        .contentShape(rounded rect radius 10)
      hit testing disabled when not logged in
    Text(votes label) .footnote, FG_2, .padding(.horizontal 4)

Draw order for the option row: BG_1 fill at bottom, then accent bar from the left, then content, clipped to radius 10, then border on top. Behavior (PVM.swift): select(optionId) guarded by !isLoading and userCanVote; tapping the selected option clears the choice (toggle) else picks it. apply is optimistic: recompute options and total, set choice, then POST polls/<id>/vote {option_uid}; on error restore previous options/total/choice and alert. Recompute (66-92): total +1 if there was no choice and now there is; -1 if there was one and now none; unchanged on switch. Per option count -1 if it is the previous choice, +1 if it is the new choice; pct = total > 0 ? round(count / total * 100) : 0 (Swift .rounded() = half away from zero), integer. votes field untouched. External poll update (poll changed) overwrites options, total, myChoice (PV.swift:31-35). Not logged in: taps ignored, no message.


10. Components/CreatePoll (CreatePollView.swift)

Strings: "Poll question" (28), "Option (index+1)" (49), "Add option" (69, icon plus). Layout (25-45):

BoxView (defaults)
  VStack(alignment .leading, spacing 10)
    TextField("Poll question") textFieldStyle .devPlace
    Divider() overlay FG_2 at 0.25
    ForEach options: HStack(spacing 10){ TextField("Option N") .devPlace;
         if options.count > 2: Button(Image "trash") plain, color red }
    if options.count < 6: Button(Label "Add option" icon plus)   (default button style, accent colored)

Rules: min 2 options (trash hidden at 2), max maxPollOptionsCount = 6 (add hidden at 6). New options are appended as "". Remove deletes at index. Return key advances focus: question -> option 0 -> option i+1 -> unfocus after last (78-87). No per-option length limit in client. No validation of empties here. Feeds: createPost poll fields (section 4.5).


11. Components/Report

Files: UI/Components/Report/ReportButton.swift (RB.swift), ReportButton+ViewModel.swift (RBVM.swift).

11.1 Visibility

Button shown only when AppSettingsStore.showReportButtons and logged in and the author is not the current user (RB.swift:12-16).

11.2 Strings

String Cite
"Report post" / "Report comment" (accessibility label of flag icon) RB.swift:42; noun RBVM.swift:32-34
Sheet title "Report this post" / "Report this comment" RBVM.swift:36-38; RB.swift:74
"Cancel" (leading), "Report" (trailing) 78, 86
Section header "Why are you reporting this post?" (or comment) 134
"Selected" (checkmark accessibility) 145
"Details" section header 166
"Add any details for the moderators (optional)" placeholder 160
Failure state: "Couldn't load reasons", "Please check your connection and try again.", button "Retry" 121-125
Success alert: title "Thank you", message "This post has been reported for review." (or comment), button "OK" (cancel role) 55-62
Error alert (submit failure): "Error" / message / "OK" RBVM.swift:84

11.3 Layout

Trigger: Label("Report <noun>", systemImage "flag") icon only, plain, FG_1 (default icon size, in the 24 pt spaced action row). Opens .sheet with:

NavigationStack, inline title (sheetTitle)
  toolbar: cancellationAction "Cancel" ; confirmationAction: ProgressView if submitting else "Report" button, disabled unless canSubmit
  content:
    reasons non empty: Form (grouped list)
       Section("Why are you reporting this <noun>?"): rows Button{ HStack{ Text(reason.label) FG_1; Spacer; checkmark icon accentColor if selected } } contentShape rect; selected row has accessibility trait selected
       Section(header "Details", footer HStack{Spacer; CharacterCounterView(detail, max 2000)}):
            TextField(axis .vertical, lineLimit 3...8) (3 to 8 lines, grows)
    else if load failed: ContentUnavailableView(Label("Couldn't load reasons", exclamationmark.triangle), description, action Retry)
    else: ProgressView centered full frame

11.4 Behavior

  • On tap: prepareForPresentation() resets reason, detail, didReport, alert (RBVM.swift:48-53), then sheet opens.
  • .task loads reasons (GET reports/reasons), guarded: only if empty and not already loading; failure sets didFailToLoadReasons; Retry reloads (RBVM.swift:55-66).
  • canSubmit = reason selected, not submitting, detail utf16 count <= 2000 (44-46). Detail has no min.
  • Submit: trim detail; POST reports/<type>/<id> {reason: key, detail: trimmed or null}; success -> didReport = true, sheet dismisses, "Thank you" alert appears (RB.swift:50-54, 86-93). Failure -> alert "Error" within the sheet, sheet stays open.
  • Server note: second report on same target updates the existing open report (SDK comment 475-478); own content cannot be reported.

12. Model Updates and AppState+Vote / +React

Files: MU/VoteModelUpdates.swift (VMU), MU/ReactionModelUpdates.swift (RMU), AS/AppState+Vote.swift (ASV), AS/AppState+React.swift (ASR). All models are immutable value types; updates rebuild copies.

12.1 Reactions (RMU)

  • Reactions.toggling(emoji) (5-20): if mine contains emoji: count = (counts[emoji] ?? 1) - 1; if > 0 store else remove key; remove emoji from mine. Else: counts[emoji] = (counts[emoji] ?? 0) + 1; append to mine.
  • Post.replacingReactions (23-37), Comment.replacingReactions(_, children:) (39-51).
  • [Comment].updatingReaction(commentId, emoji) (53-64): recursive over children, toggles on the match by data.id.

12.2 Votes (VMU)

  • Feed.replacingPosts (4-19): copy with new posts, other fields kept.
  • Post.replacingRecentComments (21-35).
  • PostDetail.with(myVote:, starCount:, comments:, reactions:) (37-55): copy with optional overrides.
  • [Comment].updatingVote(commentId, vote) (57-68): recursive.
  • Comment.applyingVote(newVote, children) (70-93): up/down counters: remove old vote (up -1 or down -1), add new vote (up +1 or down +1); myVote = newVote.
  • Comment.replacingChildren (95-105).

12.3 AppState (ASV, ASR)

  • updatePostVoteInFeed(postId, vote, count) (ASV:4-44): no-op if feed nil or post absent; replaces data.stars = count and myVote = vote.
  • updateCommentVoteInFeed(commentId, vote) (46-52): recursive over every post's recentComments.
  • performVoteToggle(targetType, targetId, currentVote, api, apply) (58-73): used by DOUBLE TAP voting only. newVote = currentVote == .up ? .none : .up; calls apply(newVote) immediately (optimistic); then api.vote(value up) (always sends .up, server toggles); on failure apply(currentVote) (rollback) and logs only (no alert).
  • updatePostReactionInFeed, updateCommentReactionInFeed (ASR:4-20): toggle via the model methods above.
  • performReactionToggle(targetType, targetId, emoji, api, apply) (ASR:25-39): apply() once optimistically; api.react; on failure apply() again (toggle back) and log, no alert. Difference to VoteView: VoteView buttons use their own view model with alert on failure and send the tapped direction (up or down); double tap only supports up toggling and fails silently.

13. Navigation summary

  • Feed -> tap card or comment -> PostView(slug, scrollToCommentId) (push, system back button, inline title).
  • Feed / FeedPostView / PostView -> create or edit post: full-screen cover with own nav bar (Close left, Create/Save right).
  • Post header avatar -> ProfileView(username) (push) only where linksToProfile is true (post detail, comments in post detail). Feed disables it.
  • Reaction add -> sheet with emoji picker. Reaction overflow -> popover (width 300). Report -> sheet.
  • Context menus and swipe actions: none in these views. The only press-and-hold menu is the selectableTextPopover on post title, post/comment body (section 3.3).

14. Gaps and unknowns

  • Values of color tokens (BG_0, BG_1, BG_2, FG_1, FG_2, accentColor, agStart, agEnd, AFG) are Asset Catalog entries in DevPlaceIOS/DevPlaceIOS/Assets.xcassets and were not inspected here; extract them before building the C++ theme.
  • AppSettingsStore keys used: draftReplyMessage, draftPostTitle, draftPostMessage, showFeedAttachments, showFeedComments, showReportButtons (defaults not inspected).
  • Not inspected (external): AttachmentUploaderView, AttachmentViewer, MentionSuggestionsView/MentionToken, EmojiPicker, VFlowStack, DevPlaceTextEditor full behavior, UserAvatarView layout, initial loadFeed trigger, the DevPlaceError messages.
  • No measurements or screenshots were taken; all numbers are read from source.
  • Reaction popover and ContentUnavailableView/Form rendering use system styling; pixel parity requires reproducing iOS system metrics separately.
  • Comments created or edited from the feed fail silently (log only); post detail shows an alert. Preserve or unify deliberately.
254.2ms