// bottom_tab_bar.dart — 移动端底部 Tab（4 项，对照 ui_kits/mobile）
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../pangolin_theme.dart';
import '../state/app_providers.dart';
import '../state/navigation_provider.dart';
import 'pangolin_icons.dart';

class BottomTabBar extends ConsumerWidget {
  const BottomTabBar({super.key, required this.current, required this.onTap});

  final NavView current;
  final ValueChanged<NavView> onTap;

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final c = context.pangolin;
    final t = ref.watch(appTextProvider);
    final items = <({IconData icon, String label, NavView view})>[
      (icon: PangolinIcons.power, label: t.tabConnect, view: NavView.connect),
      (icon: PangolinIcons.globe, label: t.tabServers, view: NavView.servers),
      (icon: PangolinIcons.barChart, label: t.tabStats, view: NavView.stats),
      (icon: PangolinIcons.user, label: t.tabMe, view: NavView.account),
    ];
    return Container(
      decoration: BoxDecoration(
        color: c.surface,
        border: Border(top: BorderSide(color: c.border)),
      ),
      padding: const EdgeInsets.only(top: 8, bottom: 22),
      child: Row(children: [
        for (final item in items)
          Expanded(
            child: GestureDetector(
              behavior: HitTestBehavior.opaque,
              onTap: () => onTap(item.view),
              child: Column(mainAxisSize: MainAxisSize.min, children: [
                Icon(item.icon, size: 22, color: current == item.view ? c.accent : c.fg3),
                const SizedBox(height: 4),
                Text(item.label,
                    style: PangolinText.caption.copyWith(
                      color: current == item.view ? c.accent : c.fg3,
                      fontWeight: current == item.view ? FontWeight.w700 : FontWeight.w500,
                    )),
              ]),
            ),
          ),
      ]),
    );
  }
}
