style: format code
This commit is contained in:
@@ -1,11 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:topic/BottomNavBar.dart';
|
|
||||||
import 'package:topic/main.dart';
|
|
||||||
import 'package:topic/HomePage.dart';
|
|
||||||
import 'package:topic/PersonalInfo.dart';
|
|
||||||
import 'package:topic/KnowledgePage.dart';
|
|
||||||
import 'package:topic/MessagePage.dart';
|
|
||||||
import 'package:mysql_client/mysql_client.dart';
|
import 'package:mysql_client/mysql_client.dart';
|
||||||
|
|
||||||
class HistoricalRecord extends StatefulWidget {
|
class HistoricalRecord extends StatefulWidget {
|
||||||
@@ -42,7 +35,8 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
|||||||
await conn.connect();
|
await conn.connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var result = await conn.execute('SELECT HomeElderFall.*, HomeElder.heName FROM HomeElderFall JOIN HomeElder ON HomeElderFall.heId = HomeElder.heId;');
|
var result = await conn.execute(
|
||||||
|
'SELECT HomeElderFall.*, HomeElder.heName FROM HomeElderFall JOIN HomeElder ON HomeElderFall.heId = HomeElder.heId;');
|
||||||
print('Result: ${result.length} rows found.');
|
print('Result: ${result.length} rows found.');
|
||||||
|
|
||||||
if (result.rows.isEmpty) {
|
if (result.rows.isEmpty) {
|
||||||
@@ -51,7 +45,7 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_results = result.rows
|
_results = result.rows
|
||||||
.map((row) => {
|
.map((row) => {
|
||||||
'長者ID': row.colAt(0),//去裝資料庫的行數
|
'長者ID': row.colAt(0), //去裝資料庫的行數
|
||||||
'姓名': row.colAt(8),
|
'姓名': row.colAt(8),
|
||||||
'跌倒時間': row.colAt(1),
|
'跌倒時間': row.colAt(1),
|
||||||
'跌倒原因': row.colAt(2),
|
'跌倒原因': row.colAt(2),
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
// import 'dart:html';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:topic/TryPage.dart';
|
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
import 'BottomNavBar.dart';
|
import 'BottomNavBar.dart';
|
||||||
@@ -61,7 +58,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
height: 240,
|
height: 240,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
// TODO: 如果用http需要分別設定ios, android權限
|
// TODO: 如果用http需要分別設定ios, android權限
|
||||||
// TODO: 替換video_player to flutter_webView
|
|
||||||
child: WebViewWidget(
|
child: WebViewWidget(
|
||||||
controller: WebViewController()
|
controller: WebViewController()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:topic/HomePage.dart';
|
|||||||
class KnowledgePage extends StatelessWidget {
|
class KnowledgePage extends StatelessWidget {
|
||||||
final String email; // 接收來自上個頁面的 email
|
final String email; // 接收來自上個頁面的 email
|
||||||
KnowledgePage({required this.email});
|
KnowledgePage({required this.email});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ class _MessagePageState extends State<MessagePage> {
|
|||||||
height: 240,
|
height: 240,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
// TODO: 如果用http需要分別設定ios, android權限
|
// TODO: 如果用http需要分別設定ios, android權限
|
||||||
// TODO: 替換video_player to flutter_webView
|
|
||||||
child: WebViewWidget(
|
child: WebViewWidget(
|
||||||
controller: WebViewController()
|
controller: WebViewController()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
|||||||
@@ -4,21 +4,22 @@ import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:topic/NoSwipeBackRoute.dart';
|
import 'package:topic/NoSwipeBackRoute.dart';
|
||||||
import 'package:topic/main.dart';
|
import 'package:topic/main.dart';
|
||||||
/*void main() {
|
|
||||||
runApp(MaterialApp(
|
|
||||||
home: PersonalInfo(),
|
|
||||||
));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
class PersonalInfo extends StatefulWidget {
|
class PersonalInfo extends StatefulWidget {
|
||||||
final String email; // 接收來自上個頁面的 email
|
final String email; // 接收來自上個頁面的 email
|
||||||
PersonalInfo({required this.email});
|
PersonalInfo({required this.email});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PersonalInfoState createState() => _PersonalInfoState();
|
_PersonalInfoState createState() => _PersonalInfoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PersonalInfoState extends State<PersonalInfo> {
|
class _PersonalInfoState extends State<PersonalInfo> {
|
||||||
String _name = '', _phone = '', _gender = '', _address='', _email = '', _password = '';
|
String _name = '',
|
||||||
|
_phone = '',
|
||||||
|
_gender = '',
|
||||||
|
_address = '',
|
||||||
|
_email = '',
|
||||||
|
_password = '';
|
||||||
bool _isEditing = false; //是否為編輯狀態
|
bool _isEditing = false; //是否為編輯狀態
|
||||||
final TextEditingController _nameController = TextEditingController();
|
final TextEditingController _nameController = TextEditingController();
|
||||||
final TextEditingController _phoneController = TextEditingController();
|
final TextEditingController _phoneController = TextEditingController();
|
||||||
@@ -53,19 +54,20 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
try {
|
try {
|
||||||
print('ok');
|
print('ok');
|
||||||
print('狀態:$_isEditing');
|
print('狀態:$_isEditing');
|
||||||
var result = await conn.execute('SELECT * FROM HomeLogin WHERE homeemail = :email',
|
var result = await conn.execute(
|
||||||
|
'SELECT * FROM HomeLogin WHERE homeemail = :email',
|
||||||
{'email': widget.email}, // 傳入參數 email
|
{'email': widget.email}, // 傳入參數 email
|
||||||
);
|
);
|
||||||
if (result.rows.isNotEmpty) {
|
if (result.rows.isNotEmpty) {
|
||||||
//有資料
|
//有資料
|
||||||
var row = result.rows.first;
|
var row = result.rows.first;
|
||||||
setState(() {
|
setState(() {
|
||||||
_name = row.colAt(0)??'';//如果沒有資料就是空直
|
_name = row.colAt(0) ?? ''; //如果沒有資料就是空直
|
||||||
_phone = row.colAt(1)??'';
|
_phone = row.colAt(1) ?? '';
|
||||||
_gender = row.colAt(2)??'';
|
_gender = row.colAt(2) ?? '';
|
||||||
_address = row.colAt(3)??'';
|
_address = row.colAt(3) ?? '';
|
||||||
_email = row.colAt(4)??'';
|
_email = row.colAt(4) ?? '';
|
||||||
_password = row.colAt(5)??'';
|
_password = row.colAt(5) ?? '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -106,7 +108,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
await conn.execute(
|
await conn.execute(
|
||||||
'UPDATE HomeLogin SET homeName = :homeName, homePhone = :homePhone, homeGender = :homeGender, homeAddress = :homeAddress, homeEmail = :new_email, homePassword = :homePassword WHERE homeEmail = :old_email',
|
'UPDATE HomeLogin SET homeName = :homeName, homePhone = :homePhone, homeGender = :homeGender, homeAddress = :homeAddress, homeEmail = :new_email, homePassword = :homePassword WHERE homeEmail = :old_email',
|
||||||
{
|
{
|
||||||
'homeName':_nameController.text,
|
'homeName': _nameController.text,
|
||||||
'homePhone': _phoneController.text,
|
'homePhone': _phoneController.text,
|
||||||
'homeGender': _genderController.text,
|
'homeGender': _genderController.text,
|
||||||
'homeAddress': _addressController.text,
|
'homeAddress': _addressController.text,
|
||||||
@@ -171,7 +173,8 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: 100,
|
height: 100,
|
||||||
color: Color(0xFFF5E3C3),//背景底色
|
color: Color(0xFFF5E3C3),
|
||||||
|
//背景底色
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: EdgeInsets.all(10.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
@@ -187,7 +190,10 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
|
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text('姓名',style: TextStyle(fontSize: 20),),
|
title: Text(
|
||||||
|
'姓名',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
subtitle: Text(_name),
|
subtitle: Text(_name),
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(),
|
||||||
@@ -261,7 +267,10 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
: Text(_password),
|
: Text(_password),
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(),
|
||||||
SizedBox(height: 20,width: 60,),
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
width: 60,
|
||||||
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_isEditing) {
|
if (_isEditing) {
|
||||||
@@ -277,7 +286,10 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
shadowColor: Colors.transparent, // 去除陰影
|
shadowColor: Colors.transparent, // 去除陰影
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10,width: 60,),
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
width: 60,
|
||||||
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_loginOut();
|
_loginOut();
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
String password = _passwordController.text;
|
String password = _passwordController.text;
|
||||||
String code = _codeController.text;
|
String code = _codeController.text;
|
||||||
|
|
||||||
if (name == ''){
|
if (name == '') {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('用戶姓名不可為空')),
|
SnackBar(content: Text('用戶姓名不可為空')),
|
||||||
);
|
);
|
||||||
@@ -134,7 +134,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (email == ''){
|
if (email == '') {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('電子信箱不可為空')),
|
SnackBar(content: Text('電子信箱不可為空')),
|
||||||
);
|
);
|
||||||
@@ -142,7 +142,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password== ''){
|
if (password == '') {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('密碼不可為空')),
|
SnackBar(content: Text('密碼不可為空')),
|
||||||
);
|
);
|
||||||
@@ -150,7 +150,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != _generatedCode){
|
if (code != _generatedCode) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('驗證碼錯誤')),
|
SnackBar(content: Text('驗證碼錯誤')),
|
||||||
);
|
);
|
||||||
@@ -208,7 +208,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('資料庫錯誤: $e');
|
print('資料庫錯誤: $e');
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('登入失敗:系統錯誤')),
|
SnackBar(content: Text('註冊失敗:系統錯誤')),
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
await conn.close();
|
await conn.close();
|
||||||
|
|||||||
262
lib/main.dart
262
lib/main.dart
@@ -5,13 +5,14 @@ import 'package:topic/HomePage.dart';
|
|||||||
import 'package:mysql_client/mysql_client.dart';
|
import 'package:mysql_client/mysql_client.dart';
|
||||||
import 'package:topic/NoSwipeBackRoute.dart';
|
import 'package:topic/NoSwipeBackRoute.dart';
|
||||||
import 'package:topic/RegisterPage.dart';
|
import 'package:topic/RegisterPage.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(MaterialApp(
|
runApp(MaterialApp(
|
||||||
home: LoginPage(),
|
home: LoginPage(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoginPage extends StatefulWidget {//ful會改變
|
class LoginPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_LoginPageState createState() => _LoginPageState();
|
_LoginPageState createState() => _LoginPageState();
|
||||||
}
|
}
|
||||||
@@ -22,10 +23,11 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
bool _passwordNotVisible = true;
|
bool _passwordNotVisible = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {//初始化
|
void initState() {
|
||||||
|
//初始化
|
||||||
super.initState();
|
super.initState();
|
||||||
_fetchData();//連資料庫
|
_fetchData(); //連資料庫
|
||||||
_CheckPreLoginInfo();//確定有先前有無登入
|
_CheckPreLoginInfo(); //確定有先前有無登入
|
||||||
}
|
}
|
||||||
|
|
||||||
void _fetchData() async {
|
void _fetchData() async {
|
||||||
@@ -44,12 +46,12 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
await conn.connect();
|
await conn.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _CheckPreLoginInfo() async{
|
void _CheckPreLoginInfo() async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
//get user data from share preference else set empty to check not login before
|
//get user data from share preference else set empty to check not login before
|
||||||
String loginUserEmail = prefs.getString("email") ?? "";
|
String loginUserEmail = prefs.getString("email") ?? "";
|
||||||
//replace screen to HomePage if there are previous data in share preference
|
//replace screen to HomePage if there are previous data in share preference
|
||||||
if(loginUserEmail != ""){
|
if (loginUserEmail != "") {
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
NoSwipeBackRoute(
|
NoSwipeBackRoute(
|
||||||
@@ -61,134 +63,12 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setLoginInfo(String email) async{
|
void _setLoginInfo(String email) async {
|
||||||
//save user email into share preference to let app can auto login next open
|
//save user email into share preference to let app can auto login next open
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.setString("email", email);
|
prefs.setString("email", email);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
debugPaintSizeEnabled=false;
|
|
||||||
//by use PopScope and disable can Pop avoid android user pop back by back button
|
|
||||||
return PopScope(
|
|
||||||
canPop: false,
|
|
||||||
child: Scaffold(
|
|
||||||
//appBar: AppBar(
|
|
||||||
//title: Text('Demo'),
|
|
||||||
//backgroundColor: Color(0xFF81D4FA),
|
|
||||||
//),
|
|
||||||
body: SafeArea(
|
|
||||||
child: Center(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 32.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.only(bottom: 40), // 添加間距
|
|
||||||
height: 100, // 設置logo高度
|
|
||||||
child: Icon(
|
|
||||||
Icons.account_circle,
|
|
||||||
size: 100, // 設置圖標大小
|
|
||||||
color: Color(0xFF4FC3F7), // 設置圖標颜色
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'全方位照護守護者',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 32,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),//全方位照護守護者
|
|
||||||
SizedBox(height: 20),
|
|
||||||
TextField(
|
|
||||||
controller: _emailController, // 绑定電子信箱输入框的控制器
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
prefixIcon: Icon(Icons.email_outlined),//https://www.fluttericon.cn/v
|
|
||||||
labelText: '電子信箱',
|
|
||||||
),
|
|
||||||
),//電子信箱
|
|
||||||
SizedBox(height: 20),
|
|
||||||
TextField(
|
|
||||||
controller: _ageController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
prefixIcon: Icon(Icons.lock_outlined),
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: Icon(_passwordNotVisible
|
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off),
|
|
||||||
onPressed: () {
|
|
||||||
setState(
|
|
||||||
() {
|
|
||||||
_passwordNotVisible = !_passwordNotVisible;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
labelText: '密碼',
|
|
||||||
),
|
|
||||||
obscureText: _passwordNotVisible,
|
|
||||||
),//密碼
|
|
||||||
SizedBox(height: 20),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: loginBtn,/*() {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => HomePage()),
|
|
||||||
);
|
|
||||||
},*/
|
|
||||||
child: Text(' 登入'),
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Color(0xFF4FC3F7),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 50, vertical: 15),
|
|
||||||
textStyle: TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
),//登入
|
|
||||||
SizedBox(height: 10),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => RegisterPage()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text('立即註冊'),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
backgroundColor: Colors.transparent, // 無背景颜色
|
|
||||||
textStyle: TextStyle(fontSize: 18),
|
|
||||||
shadowColor: Colors.transparent, // 去除陰影
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => HomePage(
|
|
||||||
email: _emailController.text,
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text('忘記密碼'),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
backgroundColor: Colors.transparent, // 無背景颜色
|
|
||||||
textStyle: TextStyle(fontSize: 18),
|
|
||||||
shadowColor: Colors.transparent, // 去除陰影
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
void loginBtn() async {
|
void loginBtn() async {
|
||||||
final conn = await MySQLConnection.createConnection(
|
final conn = await MySQLConnection.createConnection(
|
||||||
host: '203.64.84.154',
|
host: '203.64.84.154',
|
||||||
@@ -247,4 +127,128 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
await conn.close();
|
await conn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
debugPaintSizeEnabled = false;
|
||||||
|
//by use PopScope and disable can Pop avoid android user pop back by back button
|
||||||
|
return PopScope(
|
||||||
|
canPop: false,
|
||||||
|
child: Scaffold(
|
||||||
|
body: SafeArea(
|
||||||
|
child: Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(bottom: 40), // 添加間距
|
||||||
|
height: 100, // 設置logo高度
|
||||||
|
child: Icon(
|
||||||
|
Icons.account_circle,
|
||||||
|
size: 100, // 設置圖標大小
|
||||||
|
color: Color(0xFF4FC3F7), // 設置圖標颜色
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'全方位照護守護者',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 32,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
), //全方位照護守護者
|
||||||
|
SizedBox(height: 20),
|
||||||
|
TextField(
|
||||||
|
controller: _emailController, // 绑定電子信箱输入框的控制器
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
prefixIcon: Icon(Icons.email_outlined),
|
||||||
|
//https://www.fluttericon.cn/v
|
||||||
|
labelText: '電子信箱',
|
||||||
|
),
|
||||||
|
), //電子信箱
|
||||||
|
SizedBox(height: 20),
|
||||||
|
TextField(
|
||||||
|
controller: _ageController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
prefixIcon: Icon(Icons.lock_outlined),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(_passwordNotVisible
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off),
|
||||||
|
onPressed: () {
|
||||||
|
setState(
|
||||||
|
() {
|
||||||
|
_passwordNotVisible = !_passwordNotVisible;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
labelText: '密碼',
|
||||||
|
),
|
||||||
|
obscureText: _passwordNotVisible,
|
||||||
|
), //密碼
|
||||||
|
SizedBox(height: 20),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: loginBtn,
|
||||||
|
/*() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => HomePage()),
|
||||||
|
);
|
||||||
|
},*/
|
||||||
|
child: Text(' 登入'),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Color(0xFF4FC3F7),
|
||||||
|
padding:
|
||||||
|
EdgeInsets.symmetric(horizontal: 50, vertical: 15),
|
||||||
|
textStyle: TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
|
), //登入
|
||||||
|
SizedBox(height: 10),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => RegisterPage()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Text('立即註冊'),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
backgroundColor: Colors.transparent, // 無背景颜色
|
||||||
|
textStyle: TextStyle(fontSize: 18),
|
||||||
|
shadowColor: Colors.transparent, // 去除陰影
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => HomePage(
|
||||||
|
email: _emailController.text,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Text('忘記密碼'),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
backgroundColor: Colors.transparent, // 無背景颜色
|
||||||
|
textStyle: TextStyle(fontSize: 18),
|
||||||
|
shadowColor: Colors.transparent, // 去除陰影
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user