From 1295d232bf7628e49c4743745139a898ad8e1ff1 Mon Sep 17 00:00:00 2001 From: DDsouP Date: Sat, 23 Dec 2023 18:08:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fit:=E8=A7=84=E8=8C=83=E5=B9=B6=E4=B8=B0?= =?UTF-8?q?=E5=AF=8C=E4=BA=86=E5=88=9B=E5=BB=BA=E7=8F=AD=E7=BA=A7=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=9A=84=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tea_create_class.dart | 206 +++++++++++++++++++++++++++++++------- 1 file changed, 169 insertions(+), 37 deletions(-) diff --git a/lib/tea_create_class.dart b/lib/tea_create_class.dart index a6387ad..bf3f324 100644 --- a/lib/tea_create_class.dart +++ b/lib/tea_create_class.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; -// void main() => runApp(CreateClassWidget()); +void main() => runApp(CreateClassWidget()); class CreateClassWidget extends StatefulWidget { @override @@ -10,14 +10,18 @@ class CreateClassWidget extends StatefulWidget { } class _CreateClassWidgetState extends State { - TextEditingController classNameController = TextEditingController(); - TextEditingController classTimeController = TextEditingController(); + // 输入框控制器 + List TextFieldController = List.generate(7, (index) => TextEditingController()); + // 定义两个变量来存储下拉列表选择的值 + String? selectedWeekday = '周一'; + String? selectedTime = '8:30-10:00'; @override void dispose() { // Clean up the controllers when the widget is disposed. - classNameController.dispose(); - classTimeController.dispose(); + for(int i = 0; i < TextFieldController.length; i++){ + TextFieldController[i].dispose(); + } super.dispose(); } @@ -28,6 +32,7 @@ class _CreateClassWidgetState extends State { final Height = size.height; return MaterialApp( home: Scaffold( + resizeToAvoidBottomInset: true, appBar: AppBar( backgroundColor: Colors.white, title: Text( @@ -45,16 +50,14 @@ class _CreateClassWidgetState extends State { }, ), ), - body: Container( - color: Colors.grey[100], - padding: EdgeInsets.all(0.18 * Width), + body: SingleChildScrollView( + padding: EdgeInsets.all(0.1 * Width), child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - SizedBox(height: 0.05 * Height), Container( - width: 0.82 * Width, - height: 0.15 * Height, + width: 0.88 * Width, + height: 0.08 * Height, decoration: BoxDecoration( color: Colors.white, // 设置矩形底色为白色 borderRadius: BorderRadius.circular(8), // 设置圆角 @@ -63,44 +66,172 @@ class _CreateClassWidgetState extends State { ], ), child: TextField( - controller: classNameController, + controller: TextFieldController[0], maxLines: null, maxLength: 40, decoration: InputDecoration( hintText: '输入班级名称, 如:软件工程3-4班', - contentPadding: EdgeInsets.all(16.0), + contentPadding: EdgeInsets.all(10.0), border: InputBorder.none, ), ), ), - SizedBox(height: 0.08 * Height), - Container( - width: 0.82 * Width, - height: 0.15 * Height, - decoration: BoxDecoration( - color: Colors.white, // 设置矩形底色为白色 - borderRadius: BorderRadius.circular(8), // 设置圆角 - boxShadow: [ - BoxShadow(color: Colors.grey.shade200, blurRadius: 8) - ], - ), - child: TextField( - controller: classTimeController, - maxLines: null, - maxLength: 30, - decoration: InputDecoration( - hintText: '输入上课时间段, 如:8:30-10:00', - contentPadding: EdgeInsets.all(16.0), - border: InputBorder.none, + 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], + 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], + 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], + 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(), + ), + ), + ), + 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.08 * Height), + ), + SizedBox(height: 0.04 * Height), Row( children: [ Expanded( child: MaterialButton( - //背景颜色 color: Colors.white, //边框样式 @@ -115,8 +246,9 @@ class _CreateClassWidgetState extends State { height: 0.07 * Height, //点击事件 onPressed: () { - classNameController.clear(); - classTimeController.clear(); + for(int i =0; i < TextFieldController.length; i++){ + TextFieldController[i].clear(); + } }, child: const Text( "清空", -- Gitee From 977e968358b88c6d245a1b05dbd5f8f03bf8a065 Mon Sep 17 00:00:00 2001 From: DDsouP Date: Wed, 3 Jan 2024 21:50:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fit:=E5=AE=8C=E5=96=84=E4=BA=86=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/stu_my.dart | 39 +++++++++------------------------------ lib/stu_sign.dart | 3 ++- lib/tea_my.dart | 38 ++++++++------------------------------ lib/tea_sign.dart | 5 +++-- 4 files changed, 22 insertions(+), 63 deletions(-) diff --git a/lib/stu_my.dart b/lib/stu_my.dart index b09f325..b5d31f3 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 6bbe1f3..2476328 100644 --- a/lib/stu_sign.dart +++ b/lib/stu_sign.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_repository/stu_my.dart'; void main() => runApp(stu_comsic()); @@ -58,7 +59,7 @@ class _stu_HomePageState extends State { final List _pages = [ stu_MessagesPage(), stu_ComsicPage(), - stu_MinePage(), + StuMy(), ]; @override diff --git a/lib/tea_my.dart b/lib/tea_my.dart index b07686a..1700280 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 bf43db2..14ccba5 100644 --- a/lib/tea_sign.dart +++ b/lib/tea_sign.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_repository/tea_my.dart'; import 'tea_create_class.dart'; void main() => runApp(tea_comsic()); @@ -58,7 +59,7 @@ class _tea_HomePageState extends State { final List _pages = [ tea_MessagesPage(), tea_ComsicPage(), - tea_MinePage(), + TeaMy(), ]; @override @@ -168,7 +169,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), -- Gitee