Skip to content

Commit

Permalink
TimeTable 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian0KIM committed Nov 29, 2024
1 parent 48f781f commit c76e652
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 3 deletions.
2 changes: 1 addition & 1 deletion back/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ function stopMonitoring() {
}

// 서버 시작 시 모니터링 시작
startMonitoring();
//startMonitoring();

// 저장된 데이터 조회 함수
function getStoredPredictions() {
Expand Down
Binary file added front/assets/timetables/5100.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/assets/timetables/7000.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/assets/timetables/9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added front/assets/timetables/M5107.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion front/lib/bus_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'bus_timetable_page.dart';
class BusScreen extends StatelessWidget {
const BusScreen({super.key});

Expand Down Expand Up @@ -41,41 +42,48 @@ class BusScreen extends StatelessWidget {
routeNumber: "9",
operationTime: "기점 평일 06:30~22:50, 주말 06:30~22:50",
routeInfo: "사색의광장<->금곡LG1단지.와이씨티6단지)",
context: context,
),
const SizedBox(height: 10),
_buildBusRouteCard(
routeNumber: "1112",
operationTime: "기점 평일 04:40~22:30, 주말 04:40~22:30",
routeInfo: "사색의광장<->테크노마트앞.강변역(C)",
context: context,
),
const SizedBox(height: 10),
_buildBusRouteCard(
routeNumber: "5100",
operationTime: "기점 평일 05:30~00:10, 주말 05:30~23:20",
routeInfo: "사색의광장<->신분당선강남역(중)",
context: context,
),
const SizedBox(height: 10),
_buildBusRouteCard(
routeNumber: "7000",
operationTime: "기점 평일 05:30~00:00, 주말 05:30~23:30",
routeInfo: "사색의광장<->사당역4번출구",
context: context,
),
const SizedBox(height: 10),
_buildBusRouteCard(
routeNumber: "M5107",
operationTime: "기점 평일 05:00~23:00, 주말 05:00~23:00",
routeInfo: "경희대학교<->서울역버스환승센터(6번승강장)(중)",
context: context,
),
const SizedBox(height: 10),
_buildBusRouteCard(
routeNumber: "1560A",
operationTime: "기점 평일 05:30~11:30, 주말 05:00~11:20",
routeInfo: "경희대학교<->신분당선강남역(중)",
context: context,
),
_buildBusRouteCard(
routeNumber: "1560B",
operationTime: "기점 평일 11:50~22:30, 주말 11:50~22:30",
routeInfo: "경희대학교<->신분당선강남역(중)",
context: context,
),
],
),
Expand All @@ -88,6 +96,7 @@ class BusScreen extends StatelessWidget {
required String routeNumber,
required String operationTime,
required String routeInfo,
required BuildContext context,
}) {
return Card(
shape: RoundedRectangleBorder(
Expand Down Expand Up @@ -154,7 +163,14 @@ class BusScreen extends StatelessWidget {
side: const BorderSide(color: Colors.lightBlue),
),
onPressed: () {
// 버스 시간표 조회 기능 구현
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => BusTimeTablePage(
routeNumber: routeNumber,
),
),
); // 버스 시간표 조회 기능 구현
},
child: const Text('버스 시간표 조회'),
),
Expand Down
96 changes: 96 additions & 0 deletions front/lib/bus_timetable_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class BusTimeTablePage extends StatelessWidget {
final String routeNumber;

const BusTimeTablePage({
super.key,
required this.routeNumber,
});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () => Navigator.pop(context),
),
title: const Text('버스 시간표 조회'),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
routeNumber,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
],
),
),
Expanded(
child: _buildTimeTableImage(context),
),
],
),
);
}

Widget _buildTimeTableImage(BuildContext context) {
return Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
side: const BorderSide(color: Colors.blue, width: 1),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(12.0),
child: Image.asset(
'timetables/$routeNumber.jpg',
fit: BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return Center(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(
Icons.error_outline,
size: 48,
color: Colors.grey,
),
const SizedBox(height: 16),
Text(
'$routeNumber번 버스의\n시간표 정보가 없습니다.',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 16,
color: Colors.grey,
),
),
],
),
),
);
},
),
),
),
),
),
);
}
}
8 changes: 8 additions & 0 deletions front/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.4"
no_context_navigation:
dependency: "direct main"
description:
name: no_context_navigation
sha256: ad0736853864a6c0107ea5a35297884b27a99bd1a4abf7763004fe01a4327b59
url: "https://pub.dev"
source: hosted
version: "3.0.0"
package_config:
dependency: transitive
description:
Expand Down
4 changes: 3 additions & 1 deletion front/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
no_context_navigation: ^3.0.0

dev_dependencies:
flutter_test:
Expand Down Expand Up @@ -65,7 +66,8 @@ flutter:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

assets:
- assets/timetables/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images

Expand Down

0 comments on commit c76e652

Please sign in to comment.