176 lines
5.9 KiB
Dart
176 lines
5.9 KiB
Dart
// import 'dart:html';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:topic/HistoricalRecord.dart';
|
|
import 'package:topic/PersonalInfo.dart';
|
|
import 'package:topic/KnowledgePage.dart';
|
|
import 'package:topic/MessagePage.dart';
|
|
import 'package:topic/TryPage.dart';
|
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
final String email;
|
|
|
|
HomePage({required this.email});
|
|
|
|
@override
|
|
_HomePageState createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
late WebViewController _webViewController;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
height: 100,
|
|
// APPBar height
|
|
color: Color(0xFFF5E3C3),
|
|
width: double.infinity,
|
|
padding: EdgeInsets.all(10.0),
|
|
child: Stack(children: [
|
|
Container(
|
|
padding: EdgeInsets.only(
|
|
left: MediaQuery.of(context).size.width,
|
|
top: MediaQuery.of(context).size.height / 2,
|
|
),
|
|
child: Icon(Icons.settings, size: 48, color: Colors.orange),
|
|
),
|
|
Center(
|
|
child: Text(
|
|
'全方位照護守護者',
|
|
style: TextStyle(fontSize: 24, height: 5),
|
|
),
|
|
),
|
|
|
|
])),
|
|
Container(
|
|
color: Color(0xFFFFF0E0),
|
|
margin: EdgeInsets.only(top: 5),
|
|
padding: EdgeInsets.all(16),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
height: 240,
|
|
width: double.infinity,
|
|
// TODO: 如果用http需要分別設定ios, android權限
|
|
// TODO: 替換video_player to flutter_webView
|
|
child: WebViewWidget(
|
|
controller: WebViewController()
|
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
|
..setNavigationDelegate(
|
|
NavigationDelegate(
|
|
onProgress: (int progress) {
|
|
// Update loading bar.
|
|
},
|
|
onPageStarted: (String url) {},
|
|
onPageFinished: (String url) {},
|
|
onHttpError: (HttpResponseError error) {
|
|
print("httpError");
|
|
},
|
|
onWebResourceError: (WebResourceError error) {
|
|
print("httpResourceError");
|
|
print(error.description);
|
|
},
|
|
onNavigationRequest: (NavigationRequest request) {
|
|
if (request.url.startsWith(
|
|
'http://203.64.84.154:8088/video_feed')) {
|
|
return NavigationDecision.prevent;
|
|
}
|
|
return NavigationDecision.navigate;
|
|
},
|
|
),
|
|
)
|
|
..loadRequest(Uri.parse('http://203.64.84.154:8088')),
|
|
),
|
|
),
|
|
Text(
|
|
'即時畫面',
|
|
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: GridView.count(
|
|
crossAxisCount: 2,
|
|
shrinkWrap: true,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
padding: EdgeInsets.all(16),
|
|
children: [
|
|
_buildGridItem(Icons.history_edu, '跌倒紀錄', context),
|
|
_buildGridItem(Icons.lightbulb_outline, '知識補充', context),
|
|
_buildGridItem(Icons.monitor_outlined, '切換畫面', context),
|
|
_buildGridItem(Icons.person_sharp, '個人資料', context),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildGridItem(IconData icon, String label, BuildContext context) {
|
|
return Card(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
color: Colors.white,
|
|
child: InkWell(
|
|
onTap: () {
|
|
if (label == '跌倒紀錄') {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => HistoricalRecord(
|
|
email: widget.email,
|
|
)),
|
|
);
|
|
} else if (label == '知識補充') {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => KnowledgePage(
|
|
email: widget.email,
|
|
)),
|
|
);
|
|
} else if (label == '123') {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => TryPage()),
|
|
);
|
|
} else if (label == '個人資料') {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => PersonalInfo(
|
|
email: widget.email,
|
|
)),
|
|
);
|
|
}
|
|
},
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(icon, size: 48, color: Colors.orange),
|
|
SizedBox(height: 8),
|
|
Text(label, style: TextStyle(fontSize: 16)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|