장비관리 화면을 기준으로 전체 화면 UI 일관성 개선: - 모든 화면 검색바/버튼/드롭다운 높이 40px 통일 - 테이블 헤더 패딩 vertical 10px, 행 패딩 vertical 4px 통일 - 배지 스타일 통일 (border 제거, opacity 0.9 적용) - 페이지네이션 10개 이하에서도 항상 표시 - 테이블 헤더 폰트 스타일 통일 (fontSize: 13, fontWeight: w500) 각 화면별 수정사항: 1. 장비관리: 컬럼 너비 최적화, 검색 컴포넌트 높이 명시 2. 입고지 관리: 페이지네이션 조건 개선 3. 회사관리: UnifiedSearchBar 통합, 배지 스타일 개선 4. 유지보수: ListView.builder → map() 변경, 테이블 구조 재설계 키포인트 색상을 teal로 통일하여 브랜드 일관성 확보
139 lines
4.5 KiB
Dart
139 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:superport/screens/common/theme_shadcn.dart';
|
|
|
|
/// 페이지네이션 위젯 (<< < 1 2 3 ... 10 > >>)
|
|
/// - totalCount: 전체 아이템 수
|
|
/// - currentPage: 현재 페이지 (1부터 시작)
|
|
/// - pageSize: 페이지당 아이템 수
|
|
/// - onPageChanged: 페이지 변경 콜백
|
|
class Pagination extends StatelessWidget {
|
|
final int totalCount;
|
|
final int currentPage;
|
|
final int pageSize;
|
|
final ValueChanged<int> onPageChanged;
|
|
|
|
const Pagination({
|
|
Key? key,
|
|
required this.totalCount,
|
|
required this.currentPage,
|
|
required this.pageSize,
|
|
required this.onPageChanged,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// 전체 페이지 수 계산
|
|
final int totalPages = (totalCount / pageSize).ceil();
|
|
// 페이지네이션 버튼 최대 10개
|
|
final int maxButtons = 10;
|
|
// 시작 페이지 계산
|
|
int startPage = ((currentPage - 1) ~/ maxButtons) * maxButtons + 1;
|
|
int endPage = (startPage + maxButtons - 1).clamp(1, totalPages);
|
|
|
|
List<Widget> pageButtons = [];
|
|
for (int i = startPage; i <= endPage; i++) {
|
|
pageButtons.add(
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
child: InkWell(
|
|
onTap: i == currentPage ? null : () => onPageChanged(i),
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
|
child: Container(
|
|
height: 32,
|
|
constraints: const BoxConstraints(minWidth: 32),
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
decoration: BoxDecoration(
|
|
color: i == currentPage ? ShadcnTheme.primary : Colors.transparent,
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
|
border: Border.all(
|
|
color: i == currentPage ? ShadcnTheme.primary : Colors.black,
|
|
),
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
'$i',
|
|
style: ShadcnTheme.labelMedium.copyWith(
|
|
color: i == currentPage
|
|
? ShadcnTheme.primaryForeground
|
|
: ShadcnTheme.foreground,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(vertical: ShadcnTheme.spacing4),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
// 가장 처음 페이지로 이동
|
|
_buildNavigationButton(
|
|
icon: Icons.first_page,
|
|
tooltip: '처음',
|
|
onPressed: currentPage > 1 ? () => onPageChanged(1) : null,
|
|
),
|
|
const SizedBox(width: 4),
|
|
// 이전 페이지로 이동
|
|
_buildNavigationButton(
|
|
icon: Icons.chevron_left,
|
|
tooltip: '이전',
|
|
onPressed: currentPage > 1 ? () => onPageChanged(currentPage - 1) : null,
|
|
),
|
|
const SizedBox(width: 8),
|
|
// 페이지 번호 버튼들
|
|
...pageButtons,
|
|
const SizedBox(width: 8),
|
|
// 다음 페이지로 이동
|
|
_buildNavigationButton(
|
|
icon: Icons.chevron_right,
|
|
tooltip: '다음',
|
|
onPressed: currentPage < totalPages
|
|
? () => onPageChanged(currentPage + 1)
|
|
: null,
|
|
),
|
|
const SizedBox(width: 4),
|
|
// 마짉 페이지로 이동
|
|
_buildNavigationButton(
|
|
icon: Icons.last_page,
|
|
tooltip: '마짉',
|
|
onPressed: currentPage < totalPages ? () => onPageChanged(totalPages) : null,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildNavigationButton({
|
|
required IconData icon,
|
|
required String tooltip,
|
|
VoidCallback? onPressed,
|
|
}) {
|
|
final isDisabled = onPressed == null;
|
|
return Tooltip(
|
|
message: tooltip,
|
|
child: InkWell(
|
|
onTap: onPressed,
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
|
child: Container(
|
|
height: 32,
|
|
width: 32,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
|
border: Border.all(
|
|
color: isDisabled ? ShadcnTheme.muted : Colors.black,
|
|
),
|
|
),
|
|
child: Icon(
|
|
icon,
|
|
size: 18,
|
|
color: isDisabled ? ShadcnTheme.mutedForeground : ShadcnTheme.foreground,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|