Skip to content

Commit

Permalink
✨ feat/#4: add app bar
Browse files Browse the repository at this point in the history
- add select address view
- add app bar actions

Signed-off-by: EunJiJung <bianbbc87@gmail.com>
  • Loading branch information
bianbbc87 committed Sep 26, 2024
1 parent 01a08c6 commit f0bea57
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 22 deletions.
3 changes: 3 additions & 0 deletions assets/icons/app_bar_arrow_dropdown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/app_bar_basket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/app_bar_cancel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions lib/app/config/font_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ abstract class FontSystem {
height: 1.2,
);

static const TextStyle ThinH4 = TextStyle(
fontSize: 18,
fontWeight: FontWeight.w400,
fontFamily: AppConfig.APP_FONT_STYLE,
color: Colors.black,
height: 1.333,
);

static const TextStyle H4 = TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
Expand All @@ -52,6 +60,14 @@ abstract class FontSystem {
height: 1.25,
);

static const TextStyle APPBAR = TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
fontFamily: AppConfig.APP_FONT_STYLE,
color: Colors.black,
height: 1.25,
);

static const TextStyle Sub1 = TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
Expand Down
1 change: 0 additions & 1 deletion lib/presentation/view/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class HomeScreen extends BaseScreen<HomeFoodCategoryViewModel>{
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 20),
Center(
child: HomeTypeToggleButton(),
),
Expand Down
93 changes: 93 additions & 0 deletions lib/presentation/view/root/root_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import 'package:farm04_modeul/app/config/color_system.dart';
import 'package:farm04_modeul/app/config/font_system.dart';
import 'package:farm04_modeul/app/utility/log_util.dart';
import 'package:farm04_modeul/presentation/view/home/home_screen.dart';
import 'package:farm04_modeul/presentation/widget/appbar/custom_icon_app_bar.dart';
import 'package:farm04_modeul/presentation/widget/image/svg_image_box.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:farm04_modeul/core/view/base_screen.dart';
Expand All @@ -12,6 +17,94 @@ class RootScreen extends BaseScreen<RootViewModel> {
@override
bool get extendBodyBehindAppBar => true;

@override
PreferredSizeWidget? buildAppBar(BuildContext context) {
return PreferredSize(
preferredSize: const Size.fromHeight(50),
child: Obx(() {
// 홈 화면의 경우
List<Widget> actions = viewModel.selectedIndex == 0
? [
IconButton(
icon: SvgImageBox(
assetPath: 'assets/icons/app_bar_basket.svg',
width: 30,
height: 25,
color: ColorSystem.black,
),
onPressed: () {
LogUtil.info("open basket");
},
),
IconButton(
icon: SvgImageBox(
assetPath: 'assets/icons/app_bar_cancel.svg',
width: 18,
height: 18,
color: ColorSystem.black,
),
onPressed: () {
LogUtil.info("out this service");
},
),
const SizedBox(width: 6),
]
: [
// 이외의 경우 장바구니 아이콘 삭제
IconButton(
icon: SvgImageBox(
assetPath: 'assets/icons/app_bar_cancel.svg',
width: 18,
height: 18,
color: ColorSystem.black,
),
onPressed: () {
LogUtil.info("out this service");
},
),
];

if (viewModel.selectedIndex == 0) {
return CustomIconAppBar(
actions: actions,
selectedAddress: '갈산동 362 하나아파트 303호',
);
} else {
return Container(
// 홈, 찜을 제외하고 border 추가
decoration: (viewModel.selectedIndex == 2 || viewModel.selectedIndex == 3)
? BoxDecoration(
border: Border(
bottom: BorderSide(
color: ColorSystem.neutral.shade200,
width: 1,
),
),
)
: null,
child: AppBar(
title: Center(
child: Text(
viewModel.selectedIndex == 1
? '찜'
: viewModel.selectedIndex == 2
? 'MY 배달'
: '주문 내역',
style: FontSystem.ThinH4,
),
),
surfaceTintColor: Colors.white,
backgroundColor: Colors.white,
automaticallyImplyLeading: false,
centerTitle: false,
actions: actions,
),
);
}
}),
);
}

@override
Widget buildBody(BuildContext context) {
return Obx(
Expand Down
50 changes: 29 additions & 21 deletions lib/presentation/widget/appbar/custom_icon_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
import 'package:farm04_modeul/app/config/app_routes.dart';
import 'package:farm04_modeul/app/config/font_system.dart';
import 'package:farm04_modeul/presentation/widget/image/svg_image_box.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:farm04_modeul/app/config/color_system.dart';
import 'package:get/get.dart';

class CustomIconAppBar extends StatelessWidget {
const CustomIconAppBar({
super.key,
required this.svgPath,
required this.svgWidth,
required this.svgHeight,
this.actions = const <Widget>[],
required this.selectedAddress,
});

final String svgPath;
final double svgWidth;
final double svgHeight;
final List<Widget> actions;
final String selectedAddress;

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: ColorSystem.neutral.shade200,
width: 1,
),
),
),
child: AppBar(
title: Padding(
padding: const EdgeInsets.only(left: 4.0),
child: SvgPicture.asset(
svgPath,
width: svgWidth,
height: svgHeight,
title: Row(
children: [
Text(
selectedAddress, // 선택된 주소 표시
style: FontSystem.APPBAR,
),
const SizedBox(width: 16),
GestureDetector(
onTap: () {
Get.toNamed(
AppRoutes.ROOT,
arguments: {
'address': selectedAddress, // 나중에 주소 선택 창으로 이동
},
);
},
child: SvgImageBox(
assetPath: 'assets/icons/app_bar_arrow_dropdown.svg',
width: 10,
height: 8,
color: ColorSystem.black,
),
),
],
),
surfaceTintColor: Colors.white,
backgroundColor: Colors.white,
Expand Down

0 comments on commit f0bea57

Please sign in to comment.