Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion NativeAppTemplate/UI/Shop List/ShopListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions NativeAppTemplate/UI/Shop List/ShopListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ final class ShopListViewModel {
limitCount - createdShopsCount
}

var accountName: String {
sessionController.shopkeeper?.accountName ?? ""
}

var shouldPopToRootView: Bool {
sessionController.shouldPopToRootView
}
Expand Down
41 changes: 41 additions & 0 deletions NativeAppTemplateTests/UI/Shop List/ShopListViewModelTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading