Skip to content

Commit

Permalink
busCompanyInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian0KIM committed Nov 28, 2024
1 parent ddfa7f6 commit 19c353e
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dartFront/assets/data/bus_company.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"7":
{
"name":"경희대학교학생지원센터",
"name":"학생지원센터",
"phones":{
"국제캠퍼스":"031-201-3051~4"
},
Expand Down
71 changes: 71 additions & 0 deletions front/lib/busCompany.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const Map<String, dynamic> companyData = {"1":
{
"name":"용남고속",
"phones":{
"경희대영업소":"031-273-8335",
"대표번호":"031-295-7105"
},
"address": "경희대영업소: 경기도 용인시 기흥구 덕영대로 1732 (서천동, 경희대학교 국제캠퍼스)",
"buses":["9","5100","7000"],
"url":"none"
},
"2":
{
"name":"대원고속",
"phones":{
"경희대영업소1":"031-204-6657",
"경희대영업소2":"031-206-1570",
"KD통합콜센터":"02-455-2114",
"대표번호":"031-333-8157"
},
"address":"경희대영업소: 경기도 용인시 기흥구 덕영대로 1732 (서천동, 경희대학교 국제캠퍼스)",
"buses":["1112","1560A","1560B"],
"url":"http://www.buspia.co.kr/subpage/cus/cusCen.php"
},
"3":
{
"name":"경기고속",
"phones":{
"경희대영업소1":"031-204-6657",
"경희대영업소2":"031-206-1570",
"KD통합콜센터":"02-455-2114"
},
"address":"경희대영업소: 경기도 용인시 기흥구 덕영대로 1732 (서천동, 경희대학교 국제캠퍼스)",
"buses":["M5107"],
"url":"http://www.buspia.co.kr/subpage/cus/cusCen.php"
},
"4":
{
"name":"경기도청-버스불편신고",
"phones":{
"경기도콜센터":"031-120"
},
"url":"https://www.gg.go.kr/contents/contents.do?ciIdx=1003&menuId=2287"
},
"5":
{
"name":"경기도버스운송조합",
"phones":{
"경기도버스운송조합C/S":"031-246-4211",
"대표번호":"02-455-2114"
},
"url":"https://www.gbus.or.kr/lost-items-and-civil-complaints-consultation/report-traffic-inconvenience"
},
"6":
{
"name":"경희옴부즈민원",
"phones":{
"국제캠퍼스감사팀":"031-201-2004",
"서울캠퍼스감사팀":"02-961-2360"
},
"url":"http://ombuds.khu.ac.kr/html_2013/02/01.php"
},
"7":
{
"name":"학생지원센터",
"phones":{
"국제캠퍼스":"031-201-3051~4"
},
"url":"https://www.khu.ac.kr/kor/user/contents/view.do?menuNo=200172"
}
};
165 changes: 163 additions & 2 deletions front/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

import 'busCompany.dart';
void main() {
runApp(const MyApp());
}
Expand Down Expand Up @@ -369,20 +369,23 @@ class ComplaintServiceScreen extends StatelessWidget {
routes: "9 | 5100 | 7000",
stopInfo: "교내 정류장 존재",
phone: "031-273-8335",
context: context,
),
const SizedBox(height: 10),
_buildBusInfoCard(
companyName: "대원고속",
routes: "1112 | 1560(A,B)",
stopInfo: "1112: 교내 정류장 존재\n1560: 교내 정류장 없음",
phone: "031-204-6657",
context: context,
),
const SizedBox(height: 10),
_buildBusInfoCard(
companyName: "경기고속",
routes: "M5107",
stopInfo: "교내 정류장 없음",
phone: "031-206-1570",
context: context,
),
const SizedBox(height: 10),
_buildGeneralInfoCard(
Expand All @@ -391,6 +394,7 @@ class ComplaintServiceScreen extends StatelessWidget {
phone2: "031-246-4211",
button1Text: "경기도청-버스불편신고",
button2Text: "경기도버스운송조합",
context: context,
),
const SizedBox(height: 10),
_buildGeneralInfoCard(
Expand All @@ -399,6 +403,7 @@ class ComplaintServiceScreen extends StatelessWidget {
phone2: "031-201-3051~4",
button1Text: "경희옴부즈민원",
button2Text: "학생지원센터",
context: context,
),
],
),
Expand All @@ -412,7 +417,20 @@ class ComplaintServiceScreen extends StatelessWidget {
required String routes,
required String stopInfo,
required String phone,
required BuildContext context,
}) {
String getCompanyId() {
switch (companyName) {
case "용남고속":
return "1";
case "대원고속":
return "2";
case "경기고속":
return "3";
default:
return "1";
}
}
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
Expand Down Expand Up @@ -477,6 +495,14 @@ class ComplaintServiceScreen extends StatelessWidget {
),
onPressed: () {
// 회사 정보 보기 버튼 동작
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CompanyInfoPage(
companyId: getCompanyId(),
),
),
);
},
child: const Text('회사 정보 보기'),
),
Expand Down Expand Up @@ -504,7 +530,22 @@ class ComplaintServiceScreen extends StatelessWidget {
required String phone2,
required String button1Text,
required String button2Text,
required BuildContext context,
}) {
String getCompanyId(String buttonText) {
switch (buttonText) {
case "경기도청-버스불편신고":
return "4";
case "경기도버스운송조합":
return "5";
case "경희옴부즈민원":
return "6";
case "학생지원센터":
return "7";
default:
return "4";
}
}
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
Expand Down Expand Up @@ -551,7 +592,15 @@ class ComplaintServiceScreen extends StatelessWidget {
side: const BorderSide(color: Colors.lightBlue),
),
onPressed: () {
// 첫 번째 버튼 동작
// 회사 정보 페이지로 이동
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CompanyInfoPage(
companyId: getCompanyId(button1Text),
),
),
);
},
child: Text(button1Text),
),
Expand All @@ -562,6 +611,14 @@ class ComplaintServiceScreen extends StatelessWidget {
),
onPressed: () {
// 두 번째 버튼 동작
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CompanyInfoPage(
companyId: getCompanyId(button2Text),
),
),
);
},
child: Text(button2Text),
),
Expand All @@ -573,3 +630,107 @@ class ComplaintServiceScreen extends StatelessWidget {
);
}
}
class CompanyInfoPage extends StatelessWidget {
final String companyId;

const CompanyInfoPage({super.key, required this.companyId});

@override
Widget build(BuildContext context) {
final company = companyData[companyId];

return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () => Navigator.pop(context),
),
title: Text('${company['name']} 서비스'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'회사 정보',
style: TextStyle(
fontSize: 16,
color: Colors.grey,
),
),
const SizedBox(height: 16),
_buildInfoCard(company),
],
),
),
);
}

Widget _buildInfoCard(Map<String, dynamic> company) {
return Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey.shade300),
borderRadius: BorderRadius.circular(8),
),
child: Column(
children: [
_buildInfoItem(
icon: Icons.link,
title: '웹사이트 주소',
content: company['url'] ?? 'none',
),
_buildDivider(),
_buildInfoItem(
icon: Icons.phone,
title: '전화번호',
content: _formatPhones(company['phones']),
),
if (company['address'] != null) ...[
_buildDivider(),
_buildInfoItem(
icon: Icons.home,
title: '주소',
content: company['address'],
),
],
],
),
);
}

Widget _buildInfoItem({
required IconData icon,
required String title,
required String content,
}) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(icon, size: 24, color: Colors.black54),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(content),
],
),
),
],
),
);
}

Widget _buildDivider() {
return const Divider(height: 1, thickness: 1);
}

String _formatPhones(Map<String, dynamic> phones) {
return phones.entries
.map((e) => '${e.key}: ${e.value}')
.join('\n');
}
}

0 comments on commit 19c353e

Please sign in to comment.