From f323916470ba3844aa2074a4dc2f02d79be7fcc9 Mon Sep 17 00:00:00 2001 From: dadachi Date: Sat, 4 Apr 2026 18:44:40 +0900 Subject: [PATCH] Show current organization name in shop list nav bar Display the account name as a subtitle under "Shops" in the navigation bar so users with multiple organizations can tell which one they're viewing shops for. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../UI/Shop List/ShopListView.swift | 12 +++++- .../UI/Shop List/ShopListViewModel.swift | 4 ++ .../UI/Shop List/ShopListViewModelTest.swift | 41 +++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/NativeAppTemplate/UI/Shop List/ShopListView.swift b/NativeAppTemplate/UI/Shop List/ShopListView.swift index 57f6979..a66bcdd 100644 --- a/NativeAppTemplate/UI/Shop List/ShopListView.swift +++ b/NativeAppTemplate/UI/Shop List/ShopListView.swift @@ -129,9 +129,19 @@ private extension ShopListView { } } } - .navigationTitle(String.shops) .navigationBarTitleDisplayMode(.inline) .toolbar { + ToolbarItem(placement: .principal) { + VStack(spacing: 0) { + Text(String.shops) + .font(.uiHeadline) + if !viewModel.accountName.isEmpty { + Text(viewModel.accountName) + .font(.uiCaption) + .foregroundStyle(.secondary) + } + } + } if viewModel.leftInShopSlots > 0 { ToolbarItem(placement: .navigationBarTrailing) { Button { diff --git a/NativeAppTemplate/UI/Shop List/ShopListViewModel.swift b/NativeAppTemplate/UI/Shop List/ShopListViewModel.swift index 4b6d59f..4ddce6a 100644 --- a/NativeAppTemplate/UI/Shop List/ShopListViewModel.swift +++ b/NativeAppTemplate/UI/Shop List/ShopListViewModel.swift @@ -35,6 +35,10 @@ final class ShopListViewModel { limitCount - createdShopsCount } + var accountName: String { + sessionController.shopkeeper?.accountName ?? "" + } + var shouldPopToRootView: Bool { sessionController.shouldPopToRootView } diff --git a/NativeAppTemplateTests/UI/Shop List/ShopListViewModelTest.swift b/NativeAppTemplateTests/UI/Shop List/ShopListViewModelTest.swift index d28436a..14b631a 100644 --- a/NativeAppTemplateTests/UI/Shop List/ShopListViewModelTest.swift +++ b/NativeAppTemplateTests/UI/Shop List/ShopListViewModelTest.swift @@ -46,6 +46,47 @@ struct ShopListViewModelTest { #expect(viewModel.leftInShopSlots == 3) } + @Test("Account name from shopkeeper") + func accountName() { + sessionController.shopkeeper = Shopkeeper(dictionary: [ + "id": "1", + "account_id": "1", + "personal_account_id": "1", + "account_owner_id": "1", + "account_name": "Account1", + "email": "email@example.com", + "name": "John Smith", + "time_zone": "Tokyo", + "uid": "email@example.com", + "token": "token", + "client": "client", + "expiry": "123456789" + ]) + + let viewModel = ShopListViewModel( + sessionController: sessionController, + shopRepository: shopRepository, + tabViewModel: tabViewModel, + mainTab: mainTab + ) + + #expect(viewModel.accountName == "Account1") + } + + @Test("Account name when no shopkeeper") + func accountNameEmpty() { + sessionController.shopkeeper = nil + + let viewModel = ShopListViewModel( + sessionController: sessionController, + shopRepository: shopRepository, + tabViewModel: tabViewModel, + mainTab: mainTab + ) + + #expect(viewModel.accountName == "") + } + @Test("Should pop to root view", arguments: [false, true]) func shouldPopToRootView(shouldPopToRootView: Bool) { sessionController.shouldPopToRootView = shouldPopToRootView