Open name27 opened 1 year ago
// ignore_for_file: prefer_const_constructors, avoid_unnecessary_containers
// ignore_for_file: prefer_const_literals_to_create_immutables, non_constant_identifier_names
import 'package:flutter/material.dart';
import 'package:new_project_kiosk_app/OptionCard.dart';
import 'package:new_project_kiosk_app/main_page.dart';
void main() {
runApp(const KioskApp());
}
class KioskApp extends StatelessWidget {
const KioskApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: KioskPage(),
);
}
}
import 'package:flutter/material.dart';
import 'package:new_project_kiosk_app/OptionCard.dart';
import 'package:new_project_kiosk_app/admin_page.dart';
class KioskPage extends StatefulWidget {
const KioskPage({super.key});
@override
State<KioskPage> createState() => _KioskPageState();
}
class _KioskPageState extends State<KioskPage> {
List<String> orderList = [];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: GestureDetector(
onDoubleTap: (() {
Navigator.push(context,
MaterialPageRoute(builder: (context) => AdminPage()));
}),
child: Text('분식왕 이테디 주문하기'),
),
centerTitle: true,
foregroundColor: Colors.black,
backgroundColor: Colors.transparent,
elevation: 0,
actions: [],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'주문 리스트',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
Container(
alignment: Alignment.center,
height: 50,
child: orderList.isNotEmpty
? ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: orderList.length,
itemBuilder: (context, index) {
return Chip(
label: Text(orderList[index]),
onDeleted: () {
orderList.removeAt(index);
setState(() {});
},
);
}
)
: Text('주문할 메뉴가 없습니다'),
),
SizedBox(
height: 12,
),
Text(
'음식',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
Expanded(
child: GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
children: [
InkWell(
onTap: (() {
orderList.add('떡볶이');
setState(() {});
}),
child: OptionCard(
imgUrl: 'assets/option_bokki.png', foodName: '떡볶이'),
),
InkWell(
onTap: (() {
orderList.add('맥주');
setState(() {});
}),
child: OptionCard(
imgUrl: 'assets/option_beer.png', foodName: '맥주'),
),
InkWell(
onTap: (() {
orderList.add('김밥');
setState(() {});
}),
child: OptionCard(
imgUrl: 'assets/option_kimbap.png', foodName: '김밥'),
),
InkWell(
onTap: (() {
orderList.add('오므라이스');
setState(() {});
}),
child: OptionCard(
imgUrl: 'assets/option_omurice.png',
foodName: '오므라이스'),
),
InkWell(
onTap: (() {
orderList.add('돈까스');
setState(() {});
}),
child: OptionCard(
imgUrl: 'assets/option_pork_cutlets.png',
foodName: '돈까스'),
),
InkWell(
onTap: (() {
orderList.add('라면');
setState(() {});
}),
child: OptionCard(
imgUrl: 'assets/option_ramen.png', foodName: '라면'),
),
InkWell(
onTap: (() {
orderList.add('우동');
setState(() {});
}),
child: OptionCard(
imgUrl: 'assets/option_udon.png', foodName: '우동'),
),
],
),
),
//_buiddList()
],
),
),
floatingActionButton: orderList.isNotEmpty ?
FloatingActionButton.extended(
onPressed: () {},
label: Text('결제하기'),
): null,
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat);
}
}
import 'package:flutter/material.dart';
class AdminPage extends StatelessWidget {
const AdminPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('관리자 페이지'),
),
body: Padding(
padding: const EdgeInsets.all(12.0),
child: ListView(
children: [
ListTile(
title: Text('메뉴 추가하기'),
),
ListTile(
title: Text('키오스크 화면 잠그기'),
),
ListTile(
title: Text('매장 등록 정보'),
),
],
),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
class OptionCard extends StatelessWidget {
const OptionCard({super.key, required this.imgUrl, required this.foodName});
final String imgUrl;
final String foodName;
@override
Widget build(BuildContext context) {
return Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: Image.asset(imgUrl, fit: BoxFit.cover,)
),
Text(foodName),
Text('[담기]')
]
),
);
}
}
수정사항 orderList.isEmpty == true -> orderList.isEmpty orderList.isEmpty 자체가 bool값이기 때문에 true 필요 없음