Skip to content

[1주차] 3단계 #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: soojinroh
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3af44aa
[step1] readme.md 수정 후 Pr 테스트
soojinroh Oct 31, 2022
8432b06
[step1] 무엇인가 설정 변경
soojinroh Nov 4, 2022
0ee3dbf
[step1] 장바구니 화면의 helperMethod를 widget으로 리팩토링
soojinroh Nov 4, 2022
72d48b5
[step1] storeName 위젯의 가게명과 가게이미지를 생성자로 받도록 수정
soojinroh Nov 4, 2022
e738a51
[step1] menu 속성들을 생성자로 받도록 수정
soojinroh Nov 4, 2022
e79dc18
[step1] billing위젯 속성을 생성자로 받도록 수정
soojinroh Nov 4, 2022
e41f7a6
[step1] 금액 표기시 포매터 적용
soojinroh Nov 4, 2022
617cc19
[step1] addMore 위젯을 statelessWidget으로 변경
soojinroh Nov 5, 2022
65b8b58
[step2] MenuCount buildMethod를 위젯으로 추가
soojinroh Nov 5, 2022
3a2632d
[step2] 카운트가 1일 경우 minus 버튼은 비활성
soojinroh Nov 5, 2022
780cc3e
[step2] buildMehtod내 변수 선언으로 값이 초기화됨에 따라 롤백
soojinroh Nov 5, 2022
a9fa455
[step2] MenuCounter inheritedWidget를 사용하여 메뉴 카운트 적용
soojinroh Nov 5, 2022
187e32d
[step2] MenuCountButton의 수량 증감 기능 추가
soojinroh Nov 5, 2022
9c6756e
[step2] magic number인 최소수량 값을 변수 추출
soojinroh Nov 5, 2022
b620c5e
[step2] 원화 표기 로직 CurrencyFormatter로 추출
soojinroh Nov 6, 2022
307f3a4
[step2] navigationBottomBarButton에도 menuCounter inheritedWidget 적용
soojinroh Nov 6, 2022
773c4e8
[step2] currency_formatter 파일명 변경
soojinroh Nov 6, 2022
050df93
[step2] menu위젯의 멤버변수를 private으로 변경
soojinroh Nov 9, 2022
59b4dcd
[step2] store_name 위젯의 멤버변수를 private으로 변경
soojinroh Nov 9, 2022
93bc986
[step2] cartScreen의 로컬 변수를 public으로 변경
soojinroh Nov 9, 2022
063fc9c
[step2] bottomNavigationBar의 멤버 변수를 private으로 변경
soojinroh Nov 9, 2022
949994b
[step2] 바뀌지 않는 변수를 상수와 불변 변수로 변경
soojinroh Nov 11, 2022
2d84ace
[step2] formatter를 build메서드가 아닌 생성자에서 호출하도록 수정
soojinroh Nov 11, 2022
0dc59b4
Merge branch 'soojinroh' of https://github.com/next-step/flutter-cart…
soojinroh Nov 11, 2022
b4d47ad
[step3] provider 라이브러리 추가
soojinroh Nov 11, 2022
ca138e7
[step3] InheritedWidget을 provider로 변경
soojinroh Nov 11, 2022
c8dcd97
[step3] part, part of 적용
soojinroh Nov 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 86 additions & 78 deletions lib/component/billing.dart
Original file line number Diff line number Diff line change
@@ -1,101 +1,109 @@
import 'package:cart_sample/model/menu_count_model.dart';
import 'package:cart_sample/utils/currency_formatter.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';

class Billing extends StatelessWidget {

final format = NumberFormat.currency(locale: "ko_KR", name: "", decimalDigits: 0 );
final int orderPrice;
final int menuPrice;
final int deliveryPrice;

Billing({Key? key, required this.orderPrice, required this.deliveryPrice}) : super(key: key);
Billing({
Key? key,
required this.menuPrice,
required this.deliveryPrice,
}) : super(key: key);

@override
Widget build(BuildContext context) {
var _deliveryPrice = format.format(deliveryPrice);
var _orderPrice = format.format(orderPrice);
var _totalPrice = format.format(orderPrice + deliveryPrice);
final _deliveryPrice = CurrencyFormatter.convert(deliveryPrice);

return Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
color: Colors.grey.withOpacity(0.3),
width: 2,
return Consumer<MenuCounterModel>(
builder: (context, menuCounter, child) => Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
color: Colors.grey.withOpacity(0.3),
width: 2,
),
),
),
),
child: Column(
children: [
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text('총 주문금액'),
Spacer(),
Text('$_orderPrice원'),
],
child: Column(
children: [
SizedBox(
height: 20,
),
),
SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text(
'배탈팁',
style: TextStyle(
fontSize: 16,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text('총 주문금액'),
Spacer(),
Text(
'${CurrencyFormatter.convert(calculateOrderPrice(menuCounter))}원'),
],
),
),
SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text(
'배탈팁',
style: TextStyle(
fontSize: 16,
),
),
),
Spacer(),
Text(
'$_deliveryPrice원',
style: TextStyle(
fontSize: 16,
Spacer(),
Text(
'$_deliveryPrice원',
style: TextStyle(
fontSize: 16,
),
),
),
],
],
),
),
),
Padding(
padding: const EdgeInsets.all(20),
child: Divider(
color: Colors.grey,
Padding(
padding: const EdgeInsets.all(20),
child: Divider(
color: Colors.grey,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text(
'결제예정금액',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
Text(
'결제예정금액',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
Spacer(),
Text(
'$_totalPrice원',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
Spacer(),
Text(
'${CurrencyFormatter.convert(deliveryPrice + (calculateOrderPrice(menuCounter)))}원',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
],
],
),
),
),
SizedBox(
height: 20,
),
],
SizedBox(
height: 20,
),
],
),
),
);
}

int calculateOrderPrice(MenuCounterModel menuCounter) =>
menuPrice * menuCounter.menuCount;
}
72 changes: 72 additions & 0 deletions lib/component/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
part of '../../screen/cart_screen.dart';

class BottomButton extends StatelessWidget {
final int _menuPrice;
final int _deliveryPrice;

const BottomButton({Key? key, required menuPrice, required deliveryPrice})
: _menuPrice = menuPrice,
_deliveryPrice = deliveryPrice,
super(key: key);

@override
Widget build(BuildContext context) {
return Consumer<MenuCounterModel>(
builder: (context, menuCount, child) => Container(
color: Colors.white,
child: SafeArea(
child: Container(
height: 65,
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 10,
),
child: ElevatedButton(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 25,
height: 25,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: Center(
child: Text(
'1',
style: TextStyle(
color: Color.fromRGBO(44, 191, 188, 1.0),
fontWeight: FontWeight.bold,
),
),
),
),
SizedBox(
width: 7,
),
Text(
'${_calculateTotalPrice(menuCount)}원 배달 주문하기',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
],
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Color.fromRGBO(44, 191, 188, 1.0),
),
),
onPressed: () {},
),
),
),
),
);
}

int _calculateTotalPrice(MenuCounterModel menuCounter) =>
_deliveryPrice + (_menuPrice * menuCounter.menuCount);
}
Loading