프로젝트 최초 커밋
This commit is contained in:
126
lib/screens/common/main_layout.dart
Normal file
126
lib/screens/common/main_layout.dart
Normal file
@@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:superport/screens/common/theme_tailwind.dart';
|
||||
|
||||
class MainLayout extends StatelessWidget {
|
||||
final String title;
|
||||
final Widget child;
|
||||
final String currentRoute;
|
||||
final List<Widget>? actions;
|
||||
final bool showBackButton;
|
||||
final Widget? floatingActionButton;
|
||||
|
||||
const MainLayout({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.child,
|
||||
required this.currentRoute,
|
||||
this.actions,
|
||||
this.showBackButton = false,
|
||||
this.floatingActionButton,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// MetronicCloud 스타일: 상단부 플랫, 여백 넓게, 타이틀/경로/버튼 스타일링
|
||||
return Scaffold(
|
||||
backgroundColor: AppThemeTailwind.surface,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 상단 앱바
|
||||
_buildAppBar(context),
|
||||
// 컨텐츠
|
||||
Expanded(child: child),
|
||||
],
|
||||
),
|
||||
floatingActionButton: floatingActionButton,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context) {
|
||||
// 상단 앱바: 경로 텍스트가 수직 중앙에 오도록 조정, 배경색/글자색 변경
|
||||
return Container(
|
||||
height: 88,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 40),
|
||||
decoration: BoxDecoration(
|
||||
color: AppThemeTailwind.surface, // 회색 배경
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: Color(0xFFF3F6F9), width: 1),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center, // Row 내에서 수직 중앙 정렬
|
||||
children: [
|
||||
// 경로 및 타이틀 영역 (수직 중앙 정렬)
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center, // Column 내에서 수직 중앙 정렬
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 경로 텍스트 (폰트 사이즈 2배, 검은색 글자)
|
||||
Text(
|
||||
_getBreadcrumb(currentRoute),
|
||||
style: TextStyle(
|
||||
fontSize: 26,
|
||||
color: AppThemeTailwind.dark,
|
||||
), // 검은색 글자
|
||||
),
|
||||
// 타이틀이 있을 때만 표시
|
||||
if (title.isNotEmpty)
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppThemeTailwind.dark,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
if (actions != null)
|
||||
Row(
|
||||
children:
|
||||
actions!
|
||||
.map(
|
||||
(w) => Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: AppThemeTailwind.muted,
|
||||
width: 1,
|
||||
),
|
||||
color: const Color(0xFFF7F8FA),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: w,
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 현재 라우트에 따라 경로 문자열을 반환하는 함수
|
||||
String _getBreadcrumb(String route) {
|
||||
// 실제 라우트에 따라 경로를 한글로 변환 (예시)
|
||||
switch (route) {
|
||||
case '/':
|
||||
case '/home':
|
||||
return '홈 / 대시보드';
|
||||
case '/equipment':
|
||||
return '홈 / 장비 관리';
|
||||
case '/company':
|
||||
return '홈 / 회사 관리';
|
||||
case '/maintenance':
|
||||
return '홈 / 유지보수 관리';
|
||||
case '/item':
|
||||
return '홈 / 물품 관리';
|
||||
default:
|
||||
return '홈';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user