diff --git a/lib/stu_my.dart b/lib/stu_my.dart index b09f325bdda997021fd98cc92abc0d08fd585917..b5d31f3341309a8f55b0d35975dd702b04d796e7 100644 --- a/lib/stu_my.dart +++ b/lib/stu_my.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; void main() { - runApp(MyApp()); + runApp(StuMy()); } -class MyApp extends StatefulWidget { +class StuMy extends StatefulWidget { @override - _MyAppState createState() => _MyAppState(); + _StuMyState createState() => _StuMyState(); } -class _MyAppState extends State { +class _StuMyState extends State { int textFieldCount = 0; TextEditingController textFieldController = TextEditingController(); int selectedButtonIndex = 0; // 添加新的变量 @@ -34,13 +34,10 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar( - title: Text('ProfilePage'), - ), body: Column( children: [ Container( - color: Colors.purple, + color: Colors.blue, padding: EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -92,7 +89,7 @@ class _MyAppState extends State { child: Container( height: 50, color: textFieldCount == 0 - ? Colors.lightGreen + ? Colors.blue : Colors.transparent, child: Center( child: Text( @@ -116,7 +113,7 @@ class _MyAppState extends State { child: Container( height: 50, color: selectedButtonIndex == 1 - ? Colors.lightGreen + ? Colors.blue : Colors.transparent, child: Center( child: Text( @@ -140,7 +137,7 @@ class _MyAppState extends State { child: Container( height: 50, color: textFieldCount ==2 - ? Colors.lightGreen + ? Colors.blue : Colors.transparent, child: Center( child: Text( @@ -164,7 +161,7 @@ class _MyAppState extends State { height: 80, decoration: BoxDecoration( border: Border.all( - color: Colors.lightGreen, + color: Colors.blue, width: 2.0, ), ), @@ -183,24 +180,6 @@ class _MyAppState extends State { ), ], ), - bottomNavigationBar: BottomNavigationBar( - currentIndex: 0, - onTap: (int index) {}, - items: [ - BottomNavigationBarItem( - icon: Icon(Icons.message), - label: '课表', - ), - BottomNavigationBarItem( - icon: Icon(Icons.home), - label: '签到', - ), - BottomNavigationBarItem( - icon: Icon(Icons.person), - label: '我的', - ), - ], - ), ), ); } diff --git a/lib/stu_sign.dart b/lib/stu_sign.dart index 32e724e2c3dbf7f86e24adaa579ca15ccb88e2e7..2476328cdebd0566ea7021de58ed96ebd2c5335c 100644 --- a/lib/stu_sign.dart +++ b/lib/stu_sign.dart @@ -1,11 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; -import 'dart:convert'; -import 'login.dart'; -import 'scan_sign.dart'; -import 'scan_add_class.dart'; +import 'package:flutter_repository/stu_my.dart'; void main() => runApp(stu_comsic()); @@ -59,11 +55,11 @@ class stu_HomePage extends StatefulWidget { } class _stu_HomePageState extends State { - int _currentIndex = 1; + int _currentIndex = 0; final List _pages = [ stu_MessagesPage(), stu_ComsicPage(), - stu_MinePage(), + StuMy(), ]; @override @@ -96,7 +92,7 @@ class _stu_HomePageState extends State { } } -class stu_ComsicPage extends StatefulWidget { +class stu_ComsicPage extends StatefulWidget{ @override _stu_ComsicPageState createState() => _stu_ComsicPageState(); } @@ -105,14 +101,12 @@ class _stu_ComsicPageState extends State { String currentTime = ""; List isChecklists = [false, false, false, false]; - @override - void initState() { + @override void initState(){ super.initState(); Timer.periodic(Duration(seconds: 1), (Timer timer) { DateTime now = DateTime.now(); // 移除小数点后的数字 - currentTime = - '${now.year}-${now.month.toString().padLeft(2, '0')}-${now.day.toString().padLeft(2, '0')} ' + currentTime = '${now.year}-${now.month.toString().padLeft(2, '0')}-${now.day.toString().padLeft(2, '0')} ' '${now.hour.toString().padLeft(2, '0')}:${now.minute.toString().padLeft(2, '0')}:${now.second.toString().padLeft(2, '0')}'; setState(() { // currentTime = DateTime.now().toString(); @@ -120,40 +114,6 @@ class _stu_ComsicPageState extends State { }); } - Future signIn() async { - String jwtToken = await retrieveJwtToken('access_token'); - if (jwtToken == '' && !isJwtExpired(jwtToken)) { - print('No JWT token found or expire.'); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => Login()), - ); - return; - } - String apiUrl = - "http://10.161.4.248:8080/v1/attendance"; // Replace with your API URL - - try { - var response = await http.post(Uri.parse(apiUrl), - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer $jwtToken" - }, - body: jsonEncode({"sign_code": "70656"})); - - if (response.statusCode == 200) { - // Handle the response - print("Sign-in successful"); - } else { - // Handle error - print("Failed to sign in: ${response.body}"); - } - } catch (e) { - // Handle exception - print("Error occurred: $e"); - } - } - @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; @@ -163,201 +123,201 @@ class _stu_ComsicPageState extends State { width: Width, height: Height, color: Colors.grey[100], // 设置底色为浅灰色 - child: Column(children: [ - SizedBox(height: 0.05 * Height), - Container( - width: 0.88 * Width, - height: 0.07 * Height, - child: Row(children: [ - SizedBox(width: 0.02 * Width), - Container( - width: 0.6 * Width, - height: 0.07 * Height, - decoration: BoxDecoration( - color: Colors.white, // 设置矩形底色为白色 - borderRadius: BorderRadius.circular(8), // 设置圆角 - boxShadow: [ - BoxShadow(color: Colors.grey.shade200, blurRadius: 8) - ], - ), - child: Center(child: stu_SelectClass())), - SizedBox(width: 0.03 * Width), - MaterialButton( - //背景颜色 - color: Colors.white, - //边框样式 - shape: const RoundedRectangleBorder( - //边框圆角 - borderRadius: BorderRadius.all( - Radius.circular(8), + child: Column( + children: [ + SizedBox(height: 0.05 * Height), + + Container( + width: 0.88 * Width, + height: 0.07 * Height, + child: Row(children: [ + SizedBox(width: 0.02 * Width), + Container( + width: 0.6 * Width, + height: 0.07 * Height, + decoration: BoxDecoration( + color: Colors.white, // 设置矩形底色为白色 + borderRadius: BorderRadius.circular(8), // 设置圆角 + boxShadow: [ + BoxShadow(color: Colors.grey.shade200, blurRadius: 8) + ], ), - ), - //按钮高度 - minWidth: 0.05 * Width, - height: 0.07 * Height, - //点击事件 - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => JoinClassPage()), - ); - }, - child: const Text( - "加入班级", - style: TextStyle(fontSize: 14, color: Colors.black87), - )) - ])), - SizedBox(height: 0.05 * Height), - Container( - width: 0.82 * Width, - height: 0.18 * Height, - decoration: BoxDecoration( - color: Colors.white, // 设置矩形底色为白色 - borderRadius: BorderRadius.circular(8), // 设置圆角 - boxShadow: [BoxShadow(color: Colors.grey.shade200, blurRadius: 8)], - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '签到方式:', - style: TextStyle(fontSize: 16), - ), - SizedBox(width: 0.05 * Width), - Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - children: [ - Checkbox( - value: isChecklists[0], - onChanged: (bool? value) { - // TODO - setState(() { - isChecklists[0] = value!; - }); - }, - ), - Text('WIFI'), - ], - ), - Row( - children: [ - Checkbox( - value: isChecklists[1], - onChanged: (bool? value) { - // TODO - setState(() { - isChecklists[1] = value!; - }); - }, + child:Center( + child: stu_SelectClass() + ) + ), + SizedBox(width: 0.03 * Width), + MaterialButton( + //背景颜色 + color: Colors.white, + //边框样式 + shape: const RoundedRectangleBorder( + //边框圆角 + borderRadius: BorderRadius.all( + Radius.circular(8), + ), ), - Text('NFC'), - ], - ), + //按钮高度 + minWidth: 0.05 * Width, + height: 0.07 * Height, + //点击事件 + onPressed: () {}, + child: const Text( + "加入班级", + style: TextStyle(fontSize: 14, color: Colors.black87), + )) + ]) + ), + + SizedBox(height: 0.05 * Height), + + Container( + width: 0.82 * Width, + height: 0.18 * Height, + decoration: BoxDecoration( + color: Colors.white, // 设置矩形底色为白色 + borderRadius: BorderRadius.circular(8), // 设置圆角 + boxShadow: [ + BoxShadow(color: Colors.grey.shade200, blurRadius: 8) ], ), - SizedBox(width: 0.05 * Width), - Column( + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Row( + Text( + '签到方式:', + style: TextStyle(fontSize: 16), + ), + SizedBox(width: 0.05 * Width), + Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - Checkbox( - value: isChecklists[2], - onChanged: (bool? value) { - // TODO - setState(() { - isChecklists[2] = value!; - }); - }, + Row( + children: [ + Checkbox( + value: isChecklists[0], + onChanged: (bool? value) { + // TODO + setState(() { + isChecklists[0] = value!; + }); + }, + ), + Text('WIFI'), + ], + ), + Row( + children: [ + Checkbox( + value: isChecklists[1], + onChanged: (bool? value) { + // TODO + setState(() { + isChecklists[1] = value!; + }); + }, + ), + Text('NFC'), + ], ), - Text('扫码'), ], ), - Row( + SizedBox(width: 0.05 * Width), + Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - Checkbox( - value: isChecklists[3], - onChanged: (bool? value) { - // TODO - setState(() { - isChecklists[3] = value!; - }); - }, + Row( + children: [ + Checkbox( + value: isChecklists[2], + onChanged: (bool? value) { + // TODO + setState(() { + isChecklists[2] = value!; + }); + }, + ), + Text('扫码'), + ], + ), + Row( + children: [ + Checkbox( + value: isChecklists[3], + onChanged: (bool? value) { + // TODO + setState(() { + isChecklists[3] = value!; + }); + }, + ), + Text('蓝牙'), + ], ), - Text('蓝牙'), ], ), ], ), - ], - ), - ), - SizedBox(height: 0.05 * Height), - Container( - width: 0.82 * Width, - height: 0.26 * Height, - decoration: BoxDecoration( - color: Colors.white, // 设置矩形底色为白色 - borderRadius: BorderRadius.circular(8), // 设置圆角 - boxShadow: [BoxShadow(color: Colors.grey.shade200, blurRadius: 8)], - ), - child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - currentTime, - style: TextStyle(fontSize: 26), ), - SizedBox(height: 0.04 * Height), - MaterialButton( - //背景颜色 - color: Colors.blue, - //边框样式 - shape: const RoundedRectangleBorder( - //边框圆角 - borderRadius: BorderRadius.all( - Radius.circular(40), - ), - ), - //按钮高度 - minWidth: 0.4 * Width, - height: 0.08 * Height, - //点击事件 - onPressed: () { - // signIn(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ScanAttendancePage()), - ); - }, - child: const Text( - "签到", - style: TextStyle(fontSize: 22, color: Colors.white), - )), + + + SizedBox(height: 0.05 * Height), + + Container( + width: 0.82 * Width, + height: 0.26 * Height, + decoration: BoxDecoration( + color: Colors.white, // 设置矩形底色为白色 + borderRadius: BorderRadius.circular(8), // 设置圆角 + boxShadow: [ + BoxShadow(color: Colors.grey.shade200, blurRadius: 8) + ], + ), + child: Column( mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( currentTime, style: TextStyle(fontSize: 26), ), + SizedBox(height: 0.04 * Height), + MaterialButton( + //背景颜色 + color: Colors.blue, + //边框样式 + shape: const RoundedRectangleBorder( + //边框圆角 + borderRadius: BorderRadius.all( + Radius.circular(40), + ), + ), + //按钮高度 + minWidth: 0.4 * Width, + height: 0.08 * Height, + //点击事件 + onPressed: () {}, + child: const Text( + "签到", + style: TextStyle(fontSize: 22, color: Colors.white), + )) , + ]), + ), ]), - ), - ]), ); } } -class stu_SelectClass extends StatefulWidget { +class stu_SelectClass extends StatefulWidget{ @override _stu_SelectClass createState() => _stu_SelectClass(); } -class _stu_SelectClass extends State { - List courseOptions = [ - '软件工程 8:30-11:50', - '机器学习导论 8:30-11:50', - '数据库系统 14:00-15:30', - '计算机网络 8:30-10:00' - ]; +class _stu_SelectClass extends State{ + + List courseOptions = ['软件工程 8:30-11:50' + , '机器学习导论 8:30-11:50' + , '数据库系统 14:00-15:30' + , '计算机网络 8:30-10:00']; String selectedValue = '软件工程 8:30-11:50'; @override - Widget build(BuildContext context) { + Widget build(BuildContext context){ final size = MediaQuery.of(context).size; final Width = size.width; final Height = size.height; @@ -374,6 +334,7 @@ class _stu_SelectClass extends State { ), child: Center( child: DropdownButton( + value: selectedValue, onChanged: (String? newValue) { setState(() { @@ -392,6 +353,7 @@ class _stu_SelectClass extends State { } } + class stu_MessagesPage extends StatelessWidget { @override Widget build(BuildContext context) { diff --git a/lib/tea_create_class.dart b/lib/tea_create_class.dart index 687d0d26cdefca3b3a8f8ae3b3237425233206b2..bf3f32437b4ab7a61b45376385bbe29f09561220 100644 --- a/lib/tea_create_class.dart +++ b/lib/tea_create_class.dart @@ -1,21 +1,8 @@ import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'login.dart'; -import 'package:http/http.dart' as http; -import 'dart:convert'; -import 'constants.dart'; -int classid = -1; -void main() => runApp(MyApp()); -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - home: CreateClassWidget(), - ); - } -} +void main() => runApp(CreateClassWidget()); class CreateClassWidget extends StatefulWidget { @override @@ -24,8 +11,7 @@ class CreateClassWidget extends StatefulWidget { class _CreateClassWidgetState extends State { // 输入框控制器 - List TextFieldController = - List.generate(7, (index) => TextEditingController()); + List TextFieldController = List.generate(7, (index) => TextEditingController()); // 定义两个变量来存储下拉列表选择的值 String? selectedWeekday = '周一'; String? selectedTime = '8:30-10:00'; @@ -33,7 +19,7 @@ class _CreateClassWidgetState extends State { @override void dispose() { // Clean up the controllers when the widget is disposed. - for (int i = 0; i < TextFieldController.length; i++) { + for(int i = 0; i < TextFieldController.length; i++){ TextFieldController[i].dispose(); } super.dispose(); @@ -73,8 +59,8 @@ class _CreateClassWidgetState extends State { width: 0.88 * Width, height: 0.08 * Height, decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), + color: Colors.white, // 设置矩形底色为白色 + borderRadius: BorderRadius.circular(8), // 设置圆角 boxShadow: [ BoxShadow(color: Colors.grey.shade200, blurRadius: 8) ], @@ -91,192 +77,176 @@ class _CreateClassWidgetState extends State { ), ), SizedBox(height: 0.05 * Height), - Container( - width: 0.88 * Width, - height: 0.5 * Height, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow(color: Colors.grey.shade200, blurRadius: 8) - ], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(6.0), - child: Text("开始日期"), - ), - Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: TextField( - controller: TextFieldController[1], - keyboardType: TextInputType.number, // 添加数字键盘 - decoration: InputDecoration( - hintText: '年', - border: OutlineInputBorder(), - ), + Container( + width: 0.88 * Width, + height: 0.5 * Height, + decoration: BoxDecoration( + color: Colors.white, // 设置矩形底色为白色 + borderRadius: BorderRadius.circular(8), // 设置圆角 + boxShadow: [ + BoxShadow(color: Colors.grey.shade200, blurRadius: 8) + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(6.0), + child: Text("开始日期"), + ), + Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: TextField( + controller: TextFieldController[1], + decoration: InputDecoration( + hintText: '年', + border: OutlineInputBorder(), ), ), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: TextField( - controller: TextFieldController[2], - keyboardType: TextInputType.number, // 添加数字键盘 - decoration: InputDecoration( - hintText: '月', - border: OutlineInputBorder(), - ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: TextField( + controller: TextFieldController[2], + decoration: InputDecoration( + hintText: '月', + border: OutlineInputBorder(), ), ), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: TextField( - controller: TextFieldController[3], - keyboardType: TextInputType.number, // 添加数字键盘 - decoration: InputDecoration( - hintText: '日', - border: OutlineInputBorder(), - ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: TextField( + controller: TextFieldController[3], + decoration: InputDecoration( + hintText: '日', + border: OutlineInputBorder(), ), ), ), - ], - ), - Padding( - padding: const EdgeInsets.all(6.0), - child: Text("结束日期"), - ), - Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: TextField( - controller: TextFieldController[4], - keyboardType: TextInputType.number, // 添加数字键盘 - decoration: InputDecoration( - hintText: '年', - border: OutlineInputBorder(), - ), + ), + ], + ), + Padding( + padding: const EdgeInsets.all(6.0), + child: Text("结束日期"), + ), + Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: TextField( + controller: TextFieldController[4], + decoration: InputDecoration( + hintText: '年', + border: OutlineInputBorder(), ), ), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: TextField( - controller: TextFieldController[5], - keyboardType: TextInputType.number, // 添加数字键盘 - decoration: InputDecoration( - hintText: '月', - border: OutlineInputBorder(), - ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: TextField( + controller: TextFieldController[5], + decoration: InputDecoration( + hintText: '月', + border: OutlineInputBorder(), ), ), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: TextField( - controller: TextFieldController[6], - keyboardType: TextInputType.number, // 添加数字键盘 - decoration: InputDecoration( - hintText: '日', - border: OutlineInputBorder(), - ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: TextField( + controller: TextFieldController[6], + decoration: InputDecoration( + hintText: '日', + border: OutlineInputBorder(), ), ), ), - ], - ), - Padding( - padding: const EdgeInsets.all(6.0), - child: Text("上课时间"), - ), - Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: DropdownButton( - value: selectedWeekday, - onChanged: (String? newValue) { - setState(() { - selectedWeekday = newValue; - }); - }, - items: [ - '周一', - '周二', - '周三', - '周四', - '周五', - '周六', - '周日' - ].map((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ), - ), + ), + ], + ), + Padding( + padding: const EdgeInsets.all(6.0), + child: Text("上课时间"), + ), + Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: DropdownButton( + value: selectedWeekday, + onChanged: (String? newValue) { + setState(() { + selectedWeekday = newValue; + }); + }, + items: ['周一', '周二','周三', '周四','周五', '周六','周日'].map((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(15.0), - child: DropdownButton( - value: selectedTime, - onChanged: (String? newValue) { - setState(() { - selectedTime = newValue; - }); - }, - items: [ - '8:30-10:00', - '10:20-11:50', - '14:00-15:30', - '15:50-17:20', - '18:50-20:10', - '20:20-21:40' - ].map((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ), - ), + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: DropdownButton( + value: selectedTime, + onChanged: (String? newValue) { + setState(() { + selectedTime = newValue; + }); + }, + items: ['8:30-10:00', '10:20-11:50', '14:00-15:30', '15:50-17:20', '18:50-20:10', '20:20-21:40'].map((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), ), - ], + ), ), ], ), + ], ), - SizedBox(height: 0.04 * Height), + ), + SizedBox(height: 0.04 * Height), Row( children: [ Expanded( child: MaterialButton( + //背景颜色 color: Colors.white, + //边框样式 shape: const RoundedRectangleBorder( + //边框圆角 borderRadius: BorderRadius.all( Radius.circular(8), ), ), - minWidth: 0.4 * Width, // 修改按钮的最小宽度 + //按钮高度 + minWidth: 0.03 * Width, height: 0.07 * Height, + //点击事件 onPressed: () { - for (int i = 0; i < TextFieldController.length; i++) { + for(int i =0; i < TextFieldController.length; i++){ TextFieldController[i].clear(); } }, @@ -288,31 +258,32 @@ class _CreateClassWidgetState extends State { SizedBox(width: 0.08 * Width), Expanded( child: MaterialButton( - color: Color.fromARGB(255, 179, 202, 193), + + //背景颜色 + color: Colors.blue, + //边框样式 shape: const RoundedRectangleBorder( + //边框圆角 borderRadius: BorderRadius.all( Radius.circular(8), ), ), - minWidth: 0.4 * Width, // 修改按钮的最小宽度 + //按钮高度 + minWidth: 0.03 * Width, height: 0.07 * Height, + //点击事件 onPressed: () { - String className = TextFieldController[0].text; - // 格式:课程开始日期||每周几上课,上课时间段|每周几上课,上课时间段|.....||课程结束日期 - // 示例:|2023.9.4|周五14:00-15:30|2024.1.15| - String classTime = - '|${TextFieldController[1].text}.${TextFieldController[2].text}.${TextFieldController[3].text}|${selectedWeekday}${selectedTime}|${TextFieldController[4].text}.${TextFieldController[5].text}.${TextFieldController[6].text}|'; - createClass(className, classTime); - // showDialog( - // context: context, - // barrierDismissible: true, - // builder: (BuildContext context) { - // return newClassCode(); - // }); + showDialog( + context: context, + barrierDismissible: true, + // Set to true if you want to dismiss the dialog on tap outside + builder: (BuildContext context) { + return newClassCode(); + }); }, child: const Text( "确认", - style: TextStyle(fontSize: 16, color: Colors.white), + style: TextStyle(fontSize: 14, color: Colors.white), )), ), ], @@ -323,59 +294,11 @@ class _CreateClassWidgetState extends State { ), ); } - - Future createClass(String name, String time) async { - String jwtToken = await retrieveJwtToken('access_token'); - if (jwtToken == '' && !isJwtExpired(jwtToken)) { - print('No JWT token found or expire.'); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => Login()), - ); - return; - } - String serverUrl = AppConstants.serverUrl; - - try { - var response = await http.post(Uri.parse('$serverUrl/v1/createClass'), - headers: { - "Content-Type": "application/json", - "Authorization": "Bearer $jwtToken" - }, - body: jsonEncode({ - "class_name": name, - "class_time": time, - })); - - if (response.statusCode == 200) { - // Handle the response - print("create Class successful"); - final Map responseData = jsonDecode(response.body); - if (responseData.containsKey('class_id')) { - setState(() { - classid = responseData['class_id']; - }); - } - showDialog( - context: context, - barrierDismissible: true, - builder: (BuildContext context) { - return newClassCode(); - }); - } else { - // Handle error - print("Failed to create Class: ${response.body}"); - } - } catch (e) { - // Handle exception - print("Error occurred: $e"); - } - } } class newClassCode extends StatelessWidget { String generateRandomQRCode() { - final String randomData = DateTime.now().toIso8601String(); + final String randomData = DateTime.now().toIso8601String(); // Generate some random data return randomData; } @@ -407,29 +330,42 @@ class newClassCode extends StatelessWidget { ], ), QrImageView( - data: classid.toString(), + data: qrData, size: 150.0, ), + SizedBox(height: 0.05 * Height), Text( - "班级邀请码: $classid", // TODO: 换成随机邀请码 - style: TextStyle(fontSize: 14, color: Colors.black87), + "班级邀请码: 6YU4R", // TODO: 换成随机邀请码 + style: TextStyle(fontSize: 14, color: Colors.black87), ), + SizedBox(height: 0.05 * Height), MaterialButton( + + //背景颜色 color: Colors.blue, + //边框样式 shape: const RoundedRectangleBorder( + //边框圆角 borderRadius: BorderRadius.all( Radius.circular(40), ), ), + //按钮高度 minWidth: 0.4 * Width, height: 0.08 * Height, + //点击事件 onPressed: () {}, child: const Text( "保存到本地", style: TextStyle(fontSize: 16, color: Colors.white), )), + + SizedBox(height: 0.05 * Height), + // Add your QR code widget here + // Add your sign-in code widget here + // Add your button here ], ), ); diff --git a/lib/tea_my.dart b/lib/tea_my.dart index b07686a1976777da69532b8043dc5dc2dcf9c45d..1700280071a5fbcdac04e569e8d8e27aa93637c5 100644 --- a/lib/tea_my.dart +++ b/lib/tea_my.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; void main() { - runApp(MyApp()); + runApp(TeaMy()); } -class MyApp extends StatefulWidget { +class TeaMy extends StatefulWidget { @override - _MyAppState createState() => _MyAppState(); + _TeaMyState createState() => _TeaMyState(); } -class _MyAppState extends State { +class _TeaMyState extends State { int _selectedIndex = 0; String _courseInfo = '课程数信息11111'; String _leaveInfo = '课程数信息11111'; @@ -105,13 +105,10 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar( - title: Text('Profile Page'), - ), body: Column( children: [ Container( - color: Colors.purple, + color: Colors.blue, padding: EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -184,7 +181,7 @@ class _MyAppState extends State { height: 80, decoration: BoxDecoration( border: Border.all( - color: Colors.lightGreen, + color: Colors.blue, width: 2.0, ), ), @@ -202,7 +199,7 @@ class _MyAppState extends State { height: 80, decoration: BoxDecoration( border: Border.all( - color: Colors.lightGreen, + color: Colors.blue, width: 2.0, ), ), @@ -269,7 +266,7 @@ class _MyAppState extends State { height: 60, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.green, + color: Colors.blue, ), ), Container( @@ -393,25 +390,6 @@ class _MyAppState extends State { ), ], ), - bottomNavigationBar: BottomNavigationBar( - currentIndex: _selectedIndex, - onTap: _onItemTapped, - items: [ - BottomNavigationBarItem( - icon: Icon(Icons.message), - label: '课表', - ), - BottomNavigationBarItem( - icon: Icon(Icons.home), - label: '签到', - ), - BottomNavigationBarItem( - icon: Icon(Icons.person), - label: '我的', - ), - ], - selectedItemColor: Colors.green, - ), ), ); } diff --git a/lib/tea_sign.dart b/lib/tea_sign.dart index c9bc5feb3159f616b1979dee98eefc90732cb251..cb7109faa4fcecb18a810805fddf2e5e4742cc72 100644 --- a/lib/tea_sign.dart +++ b/lib/tea_sign.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'tea_signcode.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_repository/tea_my.dart'; import 'tea_create_class.dart'; import 'dart:convert'; @@ -63,7 +64,7 @@ class _tea_HomePageState extends State { final List _pages = [ tea_MessagesPage(), tea_ComsicPage(), - tea_MinePage(), + TeaMy(), ]; @override @@ -214,7 +215,7 @@ class _tea_ComsicPageState extends State { }, child: const Text( "创建班级", - style: TextStyle(fontSize: 14, color: Colors.black87), + style: TextStyle(fontSize: 12, color: Colors.black87), )) ])), SizedBox(height: 0.05 * Height),