DevPlaceIOS shell inventory
Source root: DevPlaceIOS/DevPlaceIOS/ (abbreviated R/). Citations are file:line. Scope: app entry, delegate, state, stores, push, request layer, util, navigation, shared UI utils, Main/LogIn/SignUp/Settings screens, Template, plist/entitlements/assets. Feed/Messages/Notifications/Post/Profile/CreatePost/Conversation screens and UI/Components/* are out of scope here (only the pieces this shell uses are described: BoxView, CharacterCounterView, styles).
Platform facts (from DevPlaceIOS.xcodeproj/project.pbxproj): iOS deployment target 26.0 (lines 211, 269), Swift 6.0 (311), bundle id wok.DevPlaceIOS (304), marketing version 1.1.0 (303), display name DevPlace (291), category public.app-category.social-networking (293), iPhone orientations portrait + landscape left/right (298), ITSAppUsesNonExemptEncryption = NO (292), launch screen auto-generated (296). Backend base URL https://devplace.net/ (DevPlaceSwiftSDK/Sources/DevPlaceSwiftSDK/DevPlace/DevPlaceBackend.swift:4); WebSocket URL replaces https:// with wss:// (DevPlaceSwiftSDK.swift:528-530).
1. App entry: R/DevPlaceIOSApp.swift
@main struct DevPlaceIOSApp: App(3-4). AdaptsAppDelegatevia@UIApplicationDelegateAdaptor(5). Holds@State appSettings = AppSettingsStore.shared(6).init()(8-22), runs once at launch, fire-and-forgetTasks:api = .prod(10).- If keychain has both
emailandpassword(12):api.logIn(email,password)thenAppState.shared.loadFeed(api)sequentially in one Task (13-16). Errors from the Task are thrown and swallowed (Task result never observed): if login fails, the feed is NOT loaded. - Else (17-20):
AppState.shared.loadFeed(api)as anonymous.
- Scene (24-29):
WindowGroup { MainView().preferredColorScheme(appSettings.appearance.colorScheme) }..system-> nil (follow OS),.light,.dark. - Default appearance is dark (
AppSettingsStore.swift:71).
2. R/Push/AppDelegate.swift (the only AppDelegate)
final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate (4).
didFinishLaunchingWithOptions(5-11): setsUNUserNotificationCenter.current().delegate = self; returns true.didRegisterForRemoteNotificationsWithDeviceToken(13-18): forwards toPushNotificationManager.shared.didRegisterForRemoteNotifications(deviceToken:).didFailToRegisterForRemoteNotificationsWithError(20-25): forwards to manager (logs only).didReceiveRemoteNotification(userInfo)async (27-33): awaitsmanager.handleRemoteNotification(userInfo), returns.newData.willPresent notification(35-41): awaitshandleRemoteNotification(userInfo of notification); returns[.banner, .badge, .sound](foreground notifications are shown with banner, badge and sound).didReceive response(43-48): awaitsmanager.handleNotificationTap(userInfo).
3. R/Push/PushNotificationManager.swift
@MainActor final class, singleton .shared, private init (5-9). State: api (default .prod, 11), deviceTokenHex: String? (12, in memory only, not persisted).
registerForPushNotifications(api)(14-19): store api;requestAuthorization();UIApplication.shared.registerForRemoteNotifications();sendDeviceTokenToBackend(). Called fromMainViewat launch when logged in (MainView.swift:130-135) and on login transition (136-141).requestAuthorization(61-69):UNUserNotificationCenter.requestAuthorization(options: [.alert,.badge,.sound]); logsPush authorization granted: <bool>orPush authorization request failed: <error>. No in-app rationale UI.didRegisterForRemoteNotifications(deviceToken)(33-39): hex = each byte%02xjoined, lowercase; logsRegistered for APNs with device token: <hex>; thensendDeviceTokenToBackend()in a Task.didFailToRegisterForRemoteNotifications(41-43): logsFailed to register for APNs: <error>.sendDeviceTokenToBackend(71-80): guardAppState.shared.isLoggedInand hex non-nil, else silent return;api.registerPushDevice(deviceToken:); on error logsFailed to register push device with backend: <error>. SDK call:registerPushDevice(provider: .apns, deviceToken:, token:)(ProdDevPlaceApi.swift:289-295).unregisterForPushNotifications(api)(21-31): if hex exists callsapi.unregisterPushDevice; error loggedFailed to unregister push device: <error>; thenupdateAppIconBadge(0). ProdunregisterPushDeviceis a no-op after login+refresh check (297-305; backend has no unsubscribe endpoint, TODO).handleRemoteNotification(userInfo)(49-52): logsReceived push notification payload: <pretty JSON, sorted keys, or String(describing:)>(90-97), thenAppState.loadUnreadCounts(api). Payload carries no badge number; counts are refetched on every push (TODO at 45-48).handleNotificationTap(userInfo)(54-59): same refresh, then ifconversationUid(in:)non-nil setsAppState.shared.pendingConversationUid.conversationUid(99-108): readsuserInfo["url"]string,URLComponents, requirespathcontains"messages", takes query itemwith_uid, non-empty.updateAppIconBadge(count)(82-88):UNUserNotificationCenter.setBadgeCount(count); error loggedFailed to set app icon badge count: <error>.- Entitlement
aps-environment = development(R/DevPlaceIOS.entitlements:5-6). NoUIBackgroundModeskey in build settings orInfo.plist.
4. R/AppState/*
AppState.swift (@Observable @MainActor final class, singleton)
Fields (12-24): token: AuthToken?, isLoggedIn = token != nil (14), currentUser: User?, feed: Feed?, unreadNotificationCount = 0, unreadMessageCount = 0, pendingConversationUid: String?.
isCurrentUser(id)(26-28):currentUser?.id == id.loadFeed(api)(30-33):feed = api.feed()(first page) thenloadUnreadCounts. Throws on feed failure.loadUnreadCounts(api)(35-44):api.notificationCounts(); setsunreadNotificationCount = counts.notifications,unreadMessageCount = counts.messages;PushNotificationManager.updateAppIconBadge(unreadNotificationCount)(icon badge = notifications only, not messages); error loggedFailed to load unread counts: <error>. When not logged in the prod call throwsnotLoggedInand is swallowed.loadUnreadNotificationCount(46-48): alias.conversationUser(withUid, api)(50-57):api.messages(withUid:).otherUser; nil on error with logFailed to resolve conversation user for uid <uid>: <error>.loadMoreFeed(api)(59-81): needsfeedandnextCursor, else return.api.feed(before: cursor). Duplicates (bypost.id) are dropped and loggedload-more in feed returned duplicate post from backend: <id>. NewFeed= existing posts + new posts; all other fields (currentTab, currentTopic, search, nextCursor, totalMembers, postsToday, totalProjects, totalGists, topAuthors) taken from the next page.clear()(83-90): token, feed, currentUser = nil; both counts 0; pendingConversationUid nil.
AppState+Vote.swift
updatePostVoteInFeed(postId, vote, count)(4-44): replaces the matching post withdata.stars = count,myVote = vote, all else identical; no-op if feed nil or post absent.updateCommentVoteInFeed(commentId, vote)(46-52): appliesrecentComments.updatingVoteto every post.performVoteToggle(targetType,targetId,currentVote,api,apply)(58-73):newVote = currentVote == .up ? .none : .up;apply(newVote)optimistically;api.vote(..., vote: .up)(always sends.up, backend toggles); on errorapply(currentVote)and logDouble-tap vote failed: <error>. No user alert.
AppState+React.swift
updatePostReactionInFeed(postId, emoji)(4-12):post.replacingReactions(reactions.toggling(emoji)).updateCommentReactionInFeed(commentId, emoji)(14-20).performReactionToggle(targetType,targetId,emoji,api,apply)(25-39):apply()optimistic,api.react, on errorapply()again (toggle back), logReaction toggle failed: <error>. No alert.
5. R/Stores/*
AppSettingsStore (@Observable, singleton, UserDefaults.standard)
Every property writes to UserDefaults in didSet. Keys and defaults (init 69-79):
| Key | Type | Default | Notes |
|---|---|---|---|
appearance |
String raw of system/light/dark |
dark (invalid or missing gives dark) |
10, 70-71 |
showFeedAttachments |
Bool | true | 11, 72 |
showFeedComments |
Bool | true | 12, 73 |
showReportButtons |
Bool | true | 13, 74 |
recentEmojis |
[String] | [] | 14, 75; cap maxRecentEmojis = 30 (19) |
draftPostTitle |
String | "" | 15, 76 |
draftPostMessage |
String | "" | 16, 77 |
draftReplyMessage |
String | "" | 17, 78 |
recordEmojiPick(emoji)(81-85): remove existing occurrence, insert at index 0, truncate to 30.AppearanceModetitles (96-102):"System","Light","Dark";allCasesorder system, light, dark.colorScheme: nil /.light/.dark.
UserSessionStore (@Observable, singleton)
- Keychain via
SwiftKeychainWrapper,serviceName: "DevPlace"(11). Keys"email"and"password"(13-14). Values are JSON-encoded (JSONEncoderof the String) then stored as Data (72-80), accessibility.whenUnlockedThisDeviceOnly, not synchronizable. Decode failure returns nil (58-70). - Setting nil removes the key (31, 51). Set failure logs
Error: failed to store <key> in keychain. - The plaintext password is stored so the token can be silently re-obtained; there is no refresh token.
6. R/Request/**
DevPlaceApi protocol (API/DevPlaceApi.swift)
Methods (4-42): logIn, signUp, deleteAccount, feed(before), postDetail(slug), createPost, editPost, deletePost, deleteComment, editComment, createComment, profile(username?), follow/unfollow/block/unblock/mute/unmute(username), messages(withUid?), sendMessage, makeMessagesSocket(otherUserId), usersForMentioning(matching), notifications(before), openNotification(uid), notificationCounts, markNotificationRead(uid), markAllNotificationsRead, registerPushDevice, unregisterPushDevice, vote, submitPollChoice, react, reportReasons, report, uploadFile, uploadFromUrl, deleteAttachment. Convenience overloads feed(), notifications(), messages() pass nil (45-55).
Token refresh (refreshTokenIfNeeded, 65-72): if AppState.token exists and token.willExpireSoon then re-login with stored keychain credentials (logInWithStoredCredentials 57-63; silently returns if none stored) and log Refreshed token which was about to expire soon. willExpireSoon = expireTime.timeIntervalSinceNow < 3600 (SDK AuthToken.swift:15-18); token expireTime = now + expires_in seconds (AuthToken.CodingData.decoded). The log line prints even when no stored credentials exist and nothing was refreshed. Refresh happens before each request, never on a 401, with no lock (parallel requests can each re-login).
Environment (DevPlaceApi+Environment.swift): SwiftUI key \.api, default .prod (3-5, 7-11). Screens read @Environment(\.api); previews inject .mock.
ProdDevPlaceApi (API/ProdDevPlaceApi.swift)
Singleton .shared (11); logger = DevPlaceRequestLogger(), request = DevPlaceRequest(requestLogger:) (13-18, SDK client). DevPlaceApi.prod static accessor (4-8). Pattern for every authenticated method: guard AppState.shared.token else throw DevPlaceError.notLoggedIn ("Not logged in"); refreshTokenIfNeeded(); call SDK with the token captured BEFORE the refresh (so the first call after a refresh can use the stale token; methods that read the token after the refresh are feed, postDetail, profile, messagesWebSocketURL). No error mapping inside the API: errors propagate to view models, which map via AlertMessage (section 9).
| Method | SDK call | Token handling | AppState effect |
|---|---|---|---|
| logIn (20-24) | getAuthToken(email,password) then getProfile(username:nil, token:).user |
none required | sets token; sets currentUser via try? (profile failure leaves currentUser nil, login still succeeds) |
| signUp (26-28) | signUp(username,email,password,confirmPassword,birthDate,acceptTerms) |
none | none |
| deleteAccount (30-36) | deleteAccount(username,password,token) |
needs token and currentUser.username else notLoggedIn; refresh after capture |
none (caller logs out) |
| feed (38-41) | getFeed(before,token: optional) |
refresh, token optional (anonymous OK) | none |
| postDetail (43-46) | getPost(slug,token: optional) |
refresh, optional | none |
| createPost (48-54) | createPost(title,topic,content,attachments,pollQuestion,pollOptions,projectLink,token) |
required | none |
| editPost (56-62) | editPost(slug,title,topic,content,projectLink,token) |
required | none |
| deletePost (64-70) | deletePost(slug,token) |
required | none |
| deleteComment (72-78) | deleteComment(uid,token) |
required | none |
| editComment (80-86) | editComment(uid,content,token) |
required | none |
| createComment (88-94) | createComment(targetType,targetId,content,parentId,attachments,token) |
required | none |
| vote (96-102) | vote(targetType,targetId,vote,token) |
required | none |
| submitPollChoice (104-110) | submitPollChoice(pollId,optionId,token) |
required | none |
| react (112-118) | react(targetType,targetId,emoji,token) |
required | none |
| reportReasons (120-122) | getReportReasons() |
no token, no refresh | none |
| report (124-130) | report(targetType,targetId,reason,detail,token) |
required | none |
| uploadFile (132-138) | uploadFile(data,filename,mimeType,token) returns UploadResponse |
required | none |
| uploadFromUrl (140-146) | uploadFromUrl(url,filename,token) |
required | none |
| deleteAttachment (148-154) | deleteAttachment(uid,token) |
required | none |
| follow/unfollow/block/unblock/mute/unmute (156-202) | followUser/unfollowUser/blockUser/unblockUser/muteUser/unmuteUser(username,token) |
required | none |
| messages (204-210) | getMessages(withUid,token) |
required | none |
| sendMessage (212-218) | sendMessage(receiverId,content,attachments,token) |
required | none |
| makeMessagesSocket (220-224) | builds LiveMessagesSocket(receiverUid:) with a URL provider |
provider (226-239) checks token, refreshes, re-reads token, getMessagesWebSocketTicket(token), then messagesWebSocketURL(ticket: ticket.ticket); nil URL throws DevPlaceError.invalidUrl(ticket.ticket) |
none |
| usersForMentioning (241-247) | searchMessageRecipients(q:token) |
required | none |
| notifications (249-255) | getNotifications(before,token) |
required | none |
| openNotification (257-263) | openNotification(uid,token) returns NotificationOpen (ok, redirect) |
required | none |
| notificationCounts (265-271) | getNotificationCounts(token) |
required | none |
| markNotificationRead (273-279) | markNotificationRead(uid,token) |
required | none |
| markAllNotificationsRead (281-287) | markAllNotificationsRead(token) |
required | none |
| registerPushDevice (289-295) | registerPushDevice(provider: .apns, deviceToken, token) |
required | none |
| unregisterPushDevice (297-305) | none (TODO, no backend endpoint) | requires token, refresh | none |
| profile (307-319) | getProfile(username,token) |
refresh; with username: token optional; without (own profile): token required else notLoggedIn |
none |
MockDevPlaceApi (API/MockDevPlaceApi.swift)
Singleton, DevPlaceApi.mock (4-12). mockDelay(d = 1s) sleeps (15-17). Every method sleeps then calls refreshTokenIfNeeded() (no-op unless token near expiry). Delays: logIn 1 s, signUp 1 s, feed 1 s, postDetail 1 s, uploadFile 1 s, uploadFromUrl 1 s, messages 0.3 s (115-119), notifications 0.5 s, profile 0.1 s (79-83), all others 0.2 s. logIn sets token type bearer, random UUID string, expiring in 3610 s, currentUser = Profile.mock.user (20-27). Returns: Feed.mock, PostDetail.mock, Profile.mock, messages withUid == nil ? .mockInbox : .mockConversation (118), notifications .mock, counts notifications 3, messages 1 (164), openNotification redirect = target URL of the matching mock notification else /posts/a-post-with-several-attachments#comment-c6 (151-158). usersForMentioning: empty query returns UserSearch.mock, else filters its results by case-insensitive username contains. reportReasons fixed list: hate "Hate speech or discriminatory content", violence "Realistic violence or threats", harassment "Harassment or bullying", spam "Spam or unwanted promotion", other "Something else". uploadFile echoes filename, url https://example.com/<filename>, size, isImage/isVideo/isAudio by mime prefix; uploadFromUrl returns filename = given or last path component or attachment, mime application/octet-stream, size 0. Socket: MockMessagesSocket.
Sockets (Socket/*)
MessagesSocketprotocol (4-11):events: AsyncStream<ChatSocketEvent>,connect,disconnect,send(content, attachmentUids, clientId),sendTyping,sendRead(withUid).MockMessagesSocket: all methods no-ops;disconnectfinishes the stream.LiveMessagesSocket(URLSessionWebSocketTask,URLSession(.default)):connect()(23-29): idempotent; starts connection loop Task.disconnect()(31-37): inactive, cancel loop, cancel task with.goingAway.- Loop (58-89):
backoffMs = 200. Each iteration: get URL from provider (fresh ticket every connect), open task, reset backoff to 200 on open, runreceiveLoop. Errors loggedChat socket connection error: <error>only while active. After the loop ends while still active: yield.disconnected; delay = 200 ms if close code 4013, else current backoff then doubled up to a cap of 5000 ms (200, 400, 800, 1600, 3200, 5000, 5000...). LogsChat socket reconnecting in <ms>ms (closeCode: <n>); sleeps. - Receive (91-105): text frames UTF-8 decoded, binary frames passed as is, to
ChatSocketFrameDecoder.decode; undecodable logsChat socket received unrecognized frame(107-113). - Send (39-56, 115-122): frames via
ChatSocketFrameEncoder.send(receiverUid,content,attachmentUids,clientId),.typing(receiverUid),.read(withUid); sent as text frame; if no task the send is silently dropped; failure loggedChat socket send failed: <error>.
Logger.swift:DevPlaceRequestLogger.log(message)hops to MainActor and callsdlog(SDK request logging).
7. R/Util/*
DevPlaceError(DevPlaceError.swift):notLoggedIn-> "Not logged in";invalidUrl(s)-> "Invalid URL:";postNotEditable-> "This post cannot be edited" (8-17).Logging.swift:dlog(String)prints only in DEBUG builds:"\n" + "<yyyy-MM-dd HH:mm:ss.SSS> \n<message>"(11-23);dlog(Error)logs"\(error)"(25-27). Release builds log nothing.TextCharacterCounter.numberOfCharacters=text.utf16.count(UTF-16 code units, deliberately matching the web app; the backend counts differently, known bug) (1-5). Used by character counters; SignUp validation usesString.count(grapheme clusters) instead.
8. R/UI/Navigation/*
NotificationRoute(enum):.post(PostDestination),.conversation(User),.web(URL),.ownProfile(4-9).PostDestination(struct, Hashable, Identifiable):slug: String,scrollToCommentId: String?,id = self(1-6).SettingsDestination(enum Hashable):.profile(1-3).
9. R/UI/Util/AlertMessage.swift
Struct {isPresented, title, message, buttonText} (6-11). Factories:
.none(): not presented, empty strings (14-16)..presentedError(message:): title"Error", button"OK"(18-20)..presentedMessage(msg): empty title, button"OK"(71-73)..presentedError(error)(22-69) mapping, in order:CancellationError: no alert (.none()).DevPlaceError: itsmessage.KreeRequest.Error<DevPlaceApiError.CodingData>:.generalError(status, error1): error1 CancellationError gives no alert; error1 again a KreeRequest error.generalError(_, error3): if error3 is a KreeRequest error.apiError(status, error4)thend = error4.decoded; ifd.isSpecificmessage =d.messageelse"(<status>) <d.message>"; other error3 cases useerror3.localizedDescription; other error2 caseserror2.localizedDescription; other error1error1.localizedDescription. Non-generalErrorKreeRequest cases usedpApiError.description.- Anything else:
error.localizedDescription. LogsError: <error>before presenting (67).
- View extension
alert(Binding<AlertMessage>)(76-90): native.alert(title, isPresented:)with one button labeledbuttonText,role: .cancel, no action, messageText(message). Empty title renders a title-less alert.
10. Color and style tokens
Assets.xcassets (R/Assets.xcassets/*/Contents.json), components 0-1, alpha 1.0
Code refers to .BG_0/.BG_1/.BG_2/.FG_1/.FG_2 (underscored symbol names; asset folders are BG0/BG1/BG2/FG1/FG2; the symbol extension is Xcode generated, ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES, pbxproj 162/226; the exact generation rule for the underscore was not found in source) and .agStart/.agEnd/.AFG for assets AGStart/AGEnd/AFG.
| Token (asset) | Light | Dark |
|---|---|---|
| BG0 | sRGB (1.000,1.000,1.000) | sRGB (0.000,0.000,0.000) |
| BG1 (card/field fill) | P3 (0.954,0.941,1.000) | P3 (0.029,0.016,0.071) |
| BG2 (screen background) | P3 (0.913,0.880,1.000) | P3 (0.096,0.064,0.181) |
| FG1 (primary text) | P3 (0.029,0.016,0.071) | P3 (0.953,0.934,0.980) |
| FG2 (secondary text) | P3 (0.202,0.134,0.380) | P3 (0.711,0.661,0.804) |
| AccentColor (global accent, pbxproj 283) | P3 (0.930,0.456,0.272) | same (single appearance) |
| AGStart (gradient start) | P3 (0.930,0.449,0.302) | same |
| AGEnd (gradient end) | P3 (0.925,0.370,0.429) | same |
| AFG (text on gradient) | P3 (1.000,1.000,1.000) | same |
Display-P3 values; a C++ port must decide on P3 to sRGB conversion (document the choice).
App icon (AppIcon.appiconset/Contents.json)
Universal iOS 1024x1024, three slots: default DevPlace.png (file present), dark (luminosity dark) and tinted (luminosity tinted) entries with NO filename (images not supplied). Icon name AppIcon (pbxproj 282).
Info.plist / entitlements
R/Info.plistis an empty<dict/>; all keys come from build settings listed above. No privacy usage strings, no URL schemes, noUIBackgroundModes.R/DevPlaceIOS.entitlements: onlyaps-environment = development.
Styles
ScreenStyleModifier/.screenStyle(bgColor: BG_2, fgColor: FG_1): full-bleedBG_2background ignoring safe area, foreground styleFG_1(UI/Style/Screen/ScreenStyleModifier.swift:3-27).AccentGradientButtonStyle(UI/Style/ButtonStyles/AccentGradientButtonStyle.swift): label semibold (13); padding 16 horizontal, 12 vertical (14-15); background shape RoundedRectangle radius 14 or Circle (34-39) filled with linear gradientagStarttoagEnd, topLeading to bottomTrailing (19-24); background opacity 0.7 when pressed else 1 (25); shadow coloraccentColorat 0.5 opacity, radius 5 (26); label foregroundAFG(28); scale 0.95 pressed else 1.0 (29). No explicit animation (implicit system press animation). Disabled uses SwiftUI default dimming.FormButtonStyle(.form): label frame maxWidth infinity, leading alignment, rectangle content shape, foreground gray when pressed elseFG_1(FormButtonStyle.swift:3-13).DevPlaceTextFieldStyle(.devPlace): wraps the field inBoxView(backgroundColor: BG_1, borderOpacity: 0.5, cornerSize: .big, paddingSize: .small)(DevPlaceTextFieldStyle.swift:3-16).BoxView(UI/Components/BoxView.swift): content foregroundFG_1, padding by size (none 0, small 10, normal 12, big 16), overlaystrokeBorderofFG_2at opacity (default 0.25) width 1, background rounded rectBG_2default; radii small 10, normal 12, big 14 (3-56). A text field is thus: padding 10, radius 14, 1 pt borderFG_2at 0.5, fillBG_1.CharacterCounterView(UI/Components/CharacterCounterView.swift): text"<count>/<max>"using localeformatted()for both numbers; font system size12 * scale(@ScaledMetric, Dynamic Type), monospaced; textFG_2, count part red when count < min (if min given) or count > max, elseFG_2(10-23). Count via UTF-16.MarkdownTheme.swiftexists underUI/Style(out of scope).
11. MainView (R/UI/Screens/Main/MainView.swift)
Root view; TabView(selection:) with 4 Tabs (65-129), native iOS 26 tab bar (system styling; accent applies).
| Tab (value) | Label text | SF Symbol | Content | Badge |
|---|---|---|---|---|
| postsFeed | Posts (72) |
list.bullet.rectangle |
NavigationStack { FeedView(selectedPost: $feedPost, reselectSignal:) } |
none |
| messages | Messages (84) |
bubble.left.and.bubble.right |
NavigationStack(path: $messagesPath [User]) { MessagesView() } |
.badge(unreadMessageCount) (89) |
| notifications | Notifications (111) |
bell |
NavigationStack { NotificationsView(reselectSignal, onOpenPost, onOpenConversation, onOpenOwnProfile) } |
.badge(unreadNotificationCount) (116) |
| settings | Settings (124) |
gear |
NavigationStack(path: $settingsPath [SettingsDestination]) { SettingsView() } |
none |
(.badge(0) shows nothing on iOS.) Initial tab .postsFeed (10).
State (10-16): selectedTab, feedPost: PostDestination?, messagesPath, settingsPath, feedReselectSignal: Bool, notificationsReselectSignal: Bool.
Behavior:
- Tab reselect (25-46): selecting the already-selected tab toggles
feedReselectSignal(only iffeedPost == nil) ornotificationsReselectSignal; messages and settings: nothing. Screens react inonChange(e.g.FeedView.swift:61). - Notification callbacks (95-107):
onOpenPost(destination)setsfeedPost = destination; selectedTab = .postsFeed;onOpenConversation(user)setsmessagesPath = [user]; selectedTab = .messages;onOpenOwnProfilesetssettingsPath = [.profile]; selectedTab = .settings. .taskat appear (130-135): if logged in:registerForPushNotifications(api)thenopenPendingConversationIfNeeded().onChange(isLoggedIn)(136-146): true: register push + open pending conversation; false: clearmessagesPathandsettingsPath.onChange(pendingConversationUid)(147-152): non-nil: open pending conversation.openPendingConversationIfNeeded(52-62): requires logged in and pending uid; sets pending nil; resolvesconversationUser(withUid:); if foundmessagesPath = [user],selectedTab = .messages; silent no-op on failure.onChange(selectedTab)(153-157) andonChange(scenePhase == .active)(158-163):loadUnreadCounts(api)(refetch on every tab switch and every foreground).- No loading/empty/error UI at this level.
12. LogInView (R/UI/Screens/LogIn/LogInView.swift, LogInView+ViewModel.swift)
Presented via fullScreenCover from Settings (SettingsView.swift:375-380). Wraps its own NavigationStack (193).
- Title
navigationBarTitle("Sign in")(199). Toolbar.navigationplacement button, SF Symbolxmark, actiondismiss()(201-207). - Background
BG_2ignoring safe area; foregroundFG_1(195-198). - Layout (216-229):
ScrollView { VStack(spacing: 26) { textFields, logInButton, forgotPassword, createNewAccount }.padding() }(default 16 pt padding on all sides). - textFields (231-256):
VStack(spacing: 10)of two fields, with.textInputAutocapitalization(.never),.autocorrectionDisabled(),.textFieldStyle(.devPlace),.disabled(isLoading):TextField("Email"): placeholderEmail; content type emailAddress; keyboard emailAddress; return keynextmoves focus to password.SecureField("Password"): placeholderPassword; content type password; return keygocallssubmit().- Prefilled from keychain
email/passwordon ViewModel init (41-48).
- logInButton (258-274):
ZStack:ProgressView()(default spinner) opacity 1 when loading else 0; Button labelText("Sign in")frame maxWidth infinity,.accentGradient,.bold(), disabled when!canSubmit, opacity 0 while loading.canSubmit = !email.isEmpty && !password.isEmpty(350-352; no trimming, no format check). submit()(276-279): clears focus thenviewModel.logIn().logIn()(354-373): writes email and password to keychain BEFORE the request (failed credentials persist and are reused at next launch); Task:isLoading = true(defer false);api.logIn(email,password);AppState.loadUnreadNotificationCount(api);dismiss.send()closes the cover. On erroralertMessage = .presentedError(error)(title "Error", button "OK"). Login does NOT reload the feed; push registration is triggered by MainView observingisLoggedIn.- forgotPassword (281-288):
Linktohttps://devplace.net/auth/forgot-password, textForgot your password?, accent color. - createNewAccount (290-313):
ViewThatFitspicks the first that fits:HStack(spacing: 8) { text, link }elseVStack(spacing: 2) { text, link }. textDon't have an account?medium weight,FG_2. linkNavigationLinktoSignUpView()with labelCreate new accountbold, accent color. - No inline validation messages.
13. SignUpView (R/UI/Screens/SignUp/SignUpView.swift, SignUpView+ViewModel.swift)
Pushed inside LogIn's NavigationStack. Title Create account (39). Background BG_2 ignoring safe area, foreground FG_1 (35-38). Tapping anywhere (content shape rectangle) clears focus (31-34).
- Layout (53-66):
ScrollView { VStack(spacing: 26) { textFields, dateOfBirth, termsOfService, signUpButton }.padding() }. - textFields (68-139):
VStack(spacing: 10); style.devPlace, no autocapitalization, autocorrect off, disabled while loading. Each field isVStack(alignment: .leading, spacing: 4) { input; counter.padding(.horizontal, 10) }(141-151,characterCounterHorizontalPadding = 10).Username: content type username; returnnextfocuses email. Counter min 3 max 32.Email: content type emailAddress, keyboard emailAddress;nextfocuses password. Counter min 3 max 100.Password(SecureField): content type newPassword;nextfocuses confirm. Counter min 6 max 1024.Confirm password(SecureField): newPassword; returngocallssubmit(). Counter min 6 max 1024.
- dateOfBirth (153-168):
VStack(alignment: .leading, spacing: 8):DatePicker("Date of birth", selection: birthDate, in: ...Date.now, displayedComponents: .date)(default compact style), disabled while loading; footnote textYour date of birth is only used to confirm your age. It is not stored - only your age range is kept.inFG_2. DefaultbirthDate = Date.now(ViewModel 236). Frame maxWidth infinity, leading. - termsOfService (170-187):
VStack(alignment: .leading, spacing: 12):LinktextRead the Terms of Servicetohttps://devplace.net/docs/terms.html(accent);TogglelabelI accept the Terms of ServiceinFG_2, tint accent, disabled while loading; default off. - signUpButton (189-205): same ZStack spinner/button pattern as login; text
Create account,.accentGradient, bold, disabled unlesscanSubmit.canSubmit= username, email, password, confirmPassword all non-empty andtosAccepted(251-257). signUp()(259-284): firstvalidationError(); if present showspresentedError(message:)(title "Error", OK) and returns without a request. Else Task:isLoading = true;api.signUp(...)withbirthDateandacceptTerms: tosAccepted; successsucceeded.send(); failurepresentedError(error).- Validation order and exact messages (286-316), lengths via
String.count(grapheme clusters):- username length outside 3...32:
Username must be between 3 and 32 characters. - username has a character that is not letter/number/
-/_(SwiftisLetter/isNumber, Unicode aware):Username may only contain letters, numbers, hyphens, and underscores. - email length outside 3...100:
Email must be between 3 and 100 characters. - email lacks
@:Please enter a valid email address. - password length outside 6...1024:
Password must be between 6 and 1024 characters. - password differs from confirm:
The passwords do not match. - terms not accepted:
Please accept the Terms of Service to continue.
- username length outside 3...32:
- Success alert (41-47): title
Account created, messageYour account has been created. You can now sign in., buttonOKcallsdismiss()(pops back to LogIn). No auto login. No client-side age check.
14. SettingsView (R/UI/Screens/Settings/SettingsView.swift, SettingsView+ViewModel.swift)
Root of the Settings tab. screenStyle() (BG_2 / FG_1, 355); navigationTitle("Settings") (356). navigationDestination(for: SettingsDestination): .profile shows ProfileView() (357-362).
- Toolbar (363-374): only when logged out:
.topBarTrailingbuttonSign in,.buttonStyle(.glassProminent)(iOS 26 prominent glass), opensfullScreenCoverLogInView()(375-380). - Body (383-525):
Formwith.scrollContentBackground(.hidden); every section.listRowBackground(BG_1). Sections in order:- (no header) when logged in:
NavigationLink(value: .profile)with.buttonStyle(.form),Label("Profile", systemImage: "person"). When logged out the section is empty. - (no header)
Pickerbound to appearance, labelLabel("Appearance", systemImage: "circle.lefthalf.filled"), optionsSystem/Light/Dark, tint accent. Applies instantly via rootpreferredColorScheme. - header
Posts Feed: ToggleShow one attachment per post(iconphoto) bound toshowFeedAttachments; ToggleShow recent comments(icontext.bubble) bound toshowFeedComments; tint accent. - header
Violating Content: ToggleShow report buttons(iconflag) bound toshowReportButtons. - (logged in only) buttons with
.formstyle:Sign out(iconiphone.and.arrow.right.outward) opens alert titledDo you want to sign out?, buttons: system Cancel (role cancel) and destructiveSign out.Delete account(icontrash) opens alertDo you want to permanently delete your account?, buttons Cancel and destructiveDelete account; that opens a second alert titledYour account will be deleted. This cannot be undone! Do you want to proceed?, messageEnter your password to confirm., containingSecureField("Password")(content type password), buttons Cancel (clearsdeleteAccountPassword) and destructiveDelete account(copies and clears the password, thenviewModel.deleteAccount(password:)). The error alert.alert($viewModel.alertMessage)is attached here (511).
- Section headers and row metrics are native
Formstyling.
- (no header) when logged in:
- Final success alert (517-524): title
Account deleted, messageYour account has been permanently deleted., buttonOK. logOut()(ViewModel 548-554):PushNotificationManager.unregisterForPushNotifications(backend no-op, badge 0), clear keychain email and password,AppState.clear(),try? loadFeed(api)(anonymous feed). MainView clears nav paths via theisLoggedInobserver.deleteAccount(password)(556-564):api.deleteAccount(password)(SDKdeleteAccount(username,password,token)), thenlogOut(), thenaccountDeletedConfirmationPresented = true; error setsalertMessage = presentedError(error).- Persistence: all toggles and the picker go through
AppSettingsStorekeys (section 5).
15. TemplateView (R/UI/Template/*)
Scaffold only, no UI, no strings: TemplateView reads @Environment(\.api) and creates TemplateViewContent(viewModel: .init(api:)); ViewModel is @Observable holding api (TemplateView.swift:1-26, TemplateView+ViewModel.swift:1-12). Convention for every screen: outer view injects api, private ...Content view owns @State viewModel, @ViewBuilder content(). A C++ port should mirror this as View + ViewModel pairs.
16. Gaps and notes for the port
- Mock data payloads (
Feed.mock,Profile.mock, ...) live inR/Model/Mocks/*, outside this scope. - Animations: the shell defines no explicit animation durations; only the button press scale 0.95 and opacity 0.7 (implicit SwiftUI animation) and system-provided tab/navigation/alert transitions.
- System controls (tab bar, Form, DatePicker, alerts, glassProminent button) are iOS 26 native; exact pixel metrics for these are not in source and must be taken from screenshots of a real device.
- Measurements: none; this document is static source reading.