Skip to content

Commit

Permalink
FEAT: react web view 페이지 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
bianbbc87 committed Feb 14, 2024
1 parent 50048dd commit 3e76159
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class _MainScreenState extends State<MainScreen> {
// 각 탭에 해당하는 페이지 위젯
final List<Widget> _pages = [
IssueListPage(),
WebViewMap(),
StartPage(),
PostBoardPage(),
MessagesPage(),
// MessagesPage(),
// 참고 페이지(나중에 삭제)
];
Expand Down
42 changes: 19 additions & 23 deletions lib/screens/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

class AppMap extends StatefulWidget {
const AppMap({Key? key}) : super(key: key);
import 'package:webview_flutter/webview_flutter.dart';

class WebViewMap extends StatefulWidget {
@override
_AppMapState createState() => _AppMapState();
_WebViewMapState createState() => _WebViewMapState();
}

class _AppMapState extends State<AppMap> {
late GoogleMapController mapController;

final LatLng _center = const LatLng(45.521563, -122.677433);

void _onMapCreated(GoogleMapController controller) {
mapController = controller;
}
class _WebViewMapState extends State<WebViewMap> {
late WebViewController? _controller;

@override
Widget build(BuildContext context) {
return Container(
child: Scaffold(
body: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 11.0,
),
),
),
return WebView(
initialUrl: 'https://inglo-3dmap.vercel.app/',
javascriptMode: JavascriptMode.unrestricted,
onPageFinished: (url) {
// 입력 기능을 유지하기 위한 자바스크립트 주입
final script = '''
var inputs = document.querySelectorAll("input");
inputs.forEach(function(input) {
input.disabled = false;
});
''';
// WebView에 자바스크립트 주입
_controller!.evaluateJavascript(script);
},
);
}
}
32 changes: 32 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.3.0"
webview_flutter:
dependency: "direct main"
description:
name: webview_flutter
sha256: "392c1d83b70fe2495de3ea2c84531268d5b8de2de3f01086a53334d8b6030a88"
url: "https://pub.dev"
source: hosted
version: "3.0.4"
webview_flutter_android:
dependency: transitive
description:
name: webview_flutter_android
sha256: "8b3b2450e98876c70bfcead876d9390573b34b9418c19e28168b74f6cb252dbd"
url: "https://pub.dev"
source: hosted
version: "2.10.4"
webview_flutter_platform_interface:
dependency: transitive
description:
name: webview_flutter_platform_interface
sha256: "812165e4e34ca677bdfbfa58c01e33b27fd03ab5fa75b70832d4b7d4ca1fa8cf"
url: "https://pub.dev"
source: hosted
version: "1.9.5"
webview_flutter_wkwebview:
dependency: transitive
description:
name: webview_flutter_wkwebview
sha256: a5364369c758892aa487cbf59ea41d9edd10f9d9baf06a94e80f1bd1b4c7bbc0
url: "https://pub.dev"
source: hosted
version: "2.9.5"
xml:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies:
flutter_config: ^2.0.2
dropdown_button2: ^2.3.9
modal_bottom_sheet: ^3.0.0-pre
webview_flutter: ^3.0.4

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 3e76159

Please sign in to comment.