From 93bfc3e2d2907c34e22afa052d671abc2b840f94 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Tue, 7 Jul 2026 02:45:14 +0000 Subject: [PATCH] Reorganize Woo Manager mobile header and store switcher placement. Desktop store switcher now sits after search; mobile shows route-based page titles, bottom nav, and store switching inside the profile sheet. Co-authored-by: Cursor --- app/Providers/AppServiceProvider.php | 7 ++- app/Support/MobileTopbar.php | 38 ++++++++++-- config/mobile-topbar.php | 2 +- .../views/components/settings/page.blade.php | 2 +- resources/views/layouts/user.blade.php | 25 ++++++++ .../partials/mobile-bottom-nav.blade.php | 2 + .../partials/store-switcher-menu.blade.php | 27 +++++++++ .../views/partials/store-switcher.blade.php | 2 +- resources/views/partials/topbar.blade.php | 6 +- resources/views/woo/categories/form.blade.php | 2 +- .../views/woo/categories/index.blade.php | 2 +- resources/views/woo/dashboard.blade.php | 2 +- resources/views/woo/orders/index.blade.php | 2 +- resources/views/woo/pro/index.blade.php | 2 +- resources/views/woo/products/form.blade.php | 2 +- resources/views/woo/products/index.blade.php | 2 +- resources/views/woo/stores/index.blade.php | 2 +- tests/Feature/WooMobileNavTest.php | 58 +++++++++++++++++++ 18 files changed, 165 insertions(+), 20 deletions(-) create mode 100644 resources/views/partials/store-switcher-menu.blade.php create mode 100644 tests/Feature/WooMobileNavTest.php diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b86a83f..5c30484 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,6 +4,7 @@ namespace App\Providers; use App\Services\Woo\SubscriptionService; use App\Support\CurrentWooStore; +use App\Support\MobileTopbar; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\View; @@ -16,7 +17,7 @@ class AppServiceProvider extends ServiceProvider public function boot(): void { - View::composer(['partials.sidebar', 'partials.topbar'], function ($view) { + View::composer(['partials.sidebar', 'partials.topbar', 'partials.mobile-bottom-nav', 'partials.store-switcher-menu'], function ($view) { $account = ladill_account() ?? auth()->user(); $svc = app(SubscriptionService::class); $stores = app(CurrentWooStore::class); @@ -27,5 +28,9 @@ class AppServiceProvider extends ServiceProvider $view->with('wooActiveStores', $account ? $stores->activeStores($account) : collect()); $view->with('currentWooStore', $account ? $stores->resolve($account) : null); }); + + View::composer(['partials.topbar'], function ($view) { + $view->with(MobileTopbar::resolve()); + }); } } diff --git a/app/Support/MobileTopbar.php b/app/Support/MobileTopbar.php index cc91c71..154c743 100644 --- a/app/Support/MobileTopbar.php +++ b/app/Support/MobileTopbar.php @@ -2,18 +2,44 @@ namespace App\Support; +use Illuminate\Http\Request; + class MobileTopbar { - public static function resolve(): array + /** @var array */ + private const ROUTE_TITLES = [ + 'woo.dashboard' => 'Overview', + 'woo.orders.*' => 'Orders', + 'woo.products.create' => 'New product', + 'woo.products.edit' => 'Edit product', + 'woo.products.*' => 'Products', + 'woo.categories.create' => 'New category', + 'woo.categories.edit' => 'Edit category', + 'woo.categories.*' => 'Categories', + 'woo.stores.*' => 'Stores', + 'woo.settings' => 'Settings', + 'woo.pro.*' => 'Plans', + 'notifications.*' => 'Notifications', + ]; + + public static function resolve(?Request $request = null): array { + $request ??= request(); + + if ($request) { + foreach (self::ROUTE_TITLES as $pattern => $title) { + if ($request->routeIs($pattern)) { + return ['mobileTopbarTitle' => $title]; + } + } + } + $appName = config('mobile-topbar.app_name', 'Ladill'); - $title = $appName === 'Ladill' - ? 'Ladill' - : "Ladill {$appName}"; - return [ - 'mobileTopbarTitle' => $title, + 'mobileTopbarTitle' => $appName === 'Ladill' + ? 'Ladill' + : "Ladill {$appName}", ]; } } diff --git a/config/mobile-topbar.php b/config/mobile-topbar.php index 9ac615a..33d2160 100644 --- a/config/mobile-topbar.php +++ b/config/mobile-topbar.php @@ -1,5 +1,5 @@ 'Mini', + 'app_name' => 'Woo Manager', ]; diff --git a/resources/views/components/settings/page.blade.php b/resources/views/components/settings/page.blade.php index 3bc11e8..4a92a9a 100644 --- a/resources/views/components/settings/page.blade.php +++ b/resources/views/components/settings/page.blade.php @@ -2,7 +2,7 @@
merge(['class' => 'mx-auto max-w-3xl space-y-6']) }}>
-

{{ $title }}

+

{{ $title }}

@if ($description)

{{ $description }}

@endif diff --git a/resources/views/layouts/user.blade.php b/resources/views/layouts/user.blade.php index 8d2a348..0607c90 100644 --- a/resources/views/layouts/user.blade.php +++ b/resources/views/layouts/user.blade.php @@ -27,6 +27,31 @@
@auth + @php + $navUser = auth()->user(); + $navInitials = collect(explode(' ', trim((string) $navUser?->name))) + ->filter()->take(2) + ->map(fn ($part) => strtoupper(substr($part, 0, 1))) + ->implode(''); + $navAvatarUrl = $navUser && method_exists($navUser, 'avatarUrl') + ? $navUser->avatarUrl() + : ($navUser?->avatar_url ?? null); + @endphp + @include('partials.mobile-bottom-nav', [ + 'homeUrl' => route('woo.dashboard'), + 'homeActive' => request()->routeIs('woo.dashboard'), + 'searchUrl' => route('woo.orders.index'), + 'searchActive' => request()->routeIs('woo.orders.*'), + 'notificationsUrl' => route('notifications.index'), + 'notificationsActive' => request()->routeIs('notifications.*'), + 'unreadUrl' => route('notifications.unread'), + 'profileActive' => false, + 'profileName' => $navUser?->name ?? '', + 'profileSubtitle' => $navUser?->email ?? '', + 'profileMenuItems' => \App\Support\UserProfileMenu::items($navUser), + 'avatarUrl' => $navAvatarUrl, + 'initials' => $navInitials !== '' ? $navInitials : 'U', + ]) @include('partials.sso-keepalive') @include('partials.afia') @endauth diff --git a/resources/views/partials/mobile-bottom-nav.blade.php b/resources/views/partials/mobile-bottom-nav.blade.php index a308a67..7197462 100644 --- a/resources/views/partials/mobile-bottom-nav.blade.php +++ b/resources/views/partials/mobile-bottom-nav.blade.php @@ -122,6 +122,8 @@ @endif + @include('partials.store-switcher-menu', ['onNavigate' => 'profileOpen = false']) + @include('partials.user-profile-menu', [ 'items' => $profileMenuItems, 'variant' => 'sheet', diff --git a/resources/views/partials/store-switcher-menu.blade.php b/resources/views/partials/store-switcher-menu.blade.php new file mode 100644 index 0000000..6e946b7 --- /dev/null +++ b/resources/views/partials/store-switcher-menu.blade.php @@ -0,0 +1,27 @@ +@if(($wooActiveStores ?? collect())->count() > 0) +
+

Switch store

+ @foreach($wooActiveStores as $store) +
+ @csrf + + +
+ @endforeach + + Manage stores + +
+@endif diff --git a/resources/views/partials/store-switcher.blade.php b/resources/views/partials/store-switcher.blade.php index 1f29215..9bac922 100644 --- a/resources/views/partials/store-switcher.blade.php +++ b/resources/views/partials/store-switcher.blade.php @@ -1,5 +1,5 @@ @if(($wooActiveStores ?? collect())->count() > 0) -