diff --git a/back/database/index.js b/back/database/index.js index 7347220..cbb39d4 100644 --- a/back/database/index.js +++ b/back/database/index.js @@ -797,7 +797,7 @@ function stopMonitoring() { } // 서버 시작 시 모니터링 시작 -startMonitoring(); +//startMonitoring(); // 저장된 데이터 조회 함수 function getStoredPredictions() { diff --git a/front/assets/timetables/5100.jpg b/front/assets/timetables/5100.jpg new file mode 100644 index 0000000..024cd33 Binary files /dev/null and b/front/assets/timetables/5100.jpg differ diff --git a/front/assets/timetables/7000.jpg b/front/assets/timetables/7000.jpg new file mode 100644 index 0000000..ecc696b Binary files /dev/null and b/front/assets/timetables/7000.jpg differ diff --git a/front/assets/timetables/9.jpg b/front/assets/timetables/9.jpg new file mode 100644 index 0000000..18e6521 Binary files /dev/null and b/front/assets/timetables/9.jpg differ diff --git a/front/assets/timetables/M5107.jpg b/front/assets/timetables/M5107.jpg new file mode 100644 index 0000000..096ebc8 Binary files /dev/null and b/front/assets/timetables/M5107.jpg differ diff --git a/front/lib/bus_screen.dart b/front/lib/bus_screen.dart index 237312b..af6c91f 100644 --- a/front/lib/bus_screen.dart +++ b/front/lib/bus_screen.dart @@ -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}); @@ -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, ), ], ), @@ -88,6 +96,7 @@ class BusScreen extends StatelessWidget { required String routeNumber, required String operationTime, required String routeInfo, + required BuildContext context, }) { return Card( shape: RoundedRectangleBorder( @@ -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('버스 시간표 조회'), ), diff --git a/front/lib/bus_timetable_page.dart b/front/lib/bus_timetable_page.dart new file mode 100644 index 0000000..255ca7a --- /dev/null +++ b/front/lib/bus_timetable_page.dart @@ -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, + ), + ), + ], + ), + ), + ); + }, + ), + ), + ), + ), + ), + ); + } +} diff --git a/front/pubspec.lock b/front/pubspec.lock index 5621c10..40f9d68 100644 --- a/front/pubspec.lock +++ b/front/pubspec.lock @@ -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: diff --git a/front/pubspec.yaml b/front/pubspec.yaml index 3b5ec2b..f9d5419 100644 --- a/front/pubspec.yaml +++ b/front/pubspec.yaml @@ -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: @@ -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