diff --git a/lib/pages/query.dart b/lib/pages/query.dart index 51fa499..1b02a5e 100644 --- a/lib/pages/query.dart +++ b/lib/pages/query.dart @@ -10,8 +10,9 @@ import '../data.dart'; class QueryPage extends StatefulWidget { final String title; + final int type; - const QueryPage({Key? key, this.title = "查询"}) : super(key: key); + const QueryPage({Key? key, this.title = "查询", this.type = 0}) : super(key: key); @override State createState() => _QueryPageState(); @@ -29,8 +30,6 @@ class _QueryPageState extends State { } _query(BuildContext context) async { - Scaffold.of(context).removeCurrentSnackBar(); - Scaffold.of(context).showSnackBar(jwSnackBar(true, "查询中...", 10)); _next(List list) { if (list.length == 1 && list[0] == "登录过期") { Scaffold.of(context).removeCurrentSnackBar(); @@ -88,7 +87,20 @@ class _QueryPageState extends State { setState(() {}); } - await getScore().then((value) => _next(value)); + print(writeData["username"]); + if (writeData["username"] == "") { + Scaffold.of(context).removeCurrentSnackBar(); + Scaffold.of(context).showSnackBar(jwSnackBarActionL( + false, + "请先登录", + context, + 10, + )); + } else { + Scaffold.of(context).removeCurrentSnackBar(); + Scaffold.of(context).showSnackBar(jwSnackBar(true, "查询中...", 10)); + await getScore().then((value) => _next(value)); + } } @override @@ -112,13 +124,9 @@ class _QueryPageState extends State { ), SliverToBoxAdapter( child: Container( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), - decoration: BoxDecoration( - borderRadius: const BorderRadius.all(Radius.circular(6.0)), - // color: Global.homeCardsColor, - color: readColor(), - ), - margin: const EdgeInsets.fromLTRB(16, 0, 16, 16), + padding: const EdgeInsets.fromLTRB(16, 8, 16, 16), + color: readColor(), + margin: const EdgeInsets.fromLTRB(0, 0, 0, 16), child: Column( children: [ Row( @@ -143,6 +151,9 @@ class _QueryPageState extends State { }); }, ), + SizedBox( + width: 25, + ), DropdownButton( iconEnabledColor: Colors.white, isDense: true, @@ -170,7 +181,11 @@ class _QueryPageState extends State { _query(context); }, child: Container( - padding: const EdgeInsets.fromLTRB(16, 16, 0, 16), + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + color: Color(0x1ff1f1f1), + ), + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), child: Text( "查询", style: TextStyle(color: Colors.white), @@ -179,35 +194,33 @@ class _QueryPageState extends State { }) ], ), - ], - ), - ), - ), - SliverToBoxAdapter( - child: Container( - padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "GPA绩点: $_gpa", - style: TextStyle(), - ), - Text( - "|", - style: TextStyle(color: readColor()), - ), - Text( - "算术平均分: $_avg", - style: TextStyle(), - ), - Text( - "|", - style: TextStyle(color: readColor()), + SizedBox( + height: 8, ), - Text( - "加权平均分: $_weight", - style: TextStyle(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "GPA绩点: $_gpa", + style: TextStyle(color: Colors.white), + ), + Text( + "|", + style: TextStyle(color: readColor()), + ), + Text( + "算术平均分: $_avg", + style: TextStyle(color: Colors.white), + ), + Text( + "|", + style: TextStyle(color: readColor()), + ), + Text( + "加权平均分: $_weight", + style: TextStyle(color: Colors.white), + ) + ], ) ], ), diff --git a/lib/widget/bars.dart b/lib/widget/bars.dart index 70048eb..7fad114 100644 --- a/lib/widget/bars.dart +++ b/lib/widget/bars.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:glutassistantn/config.dart'; +import 'package:glutassistantn/pages/login.dart'; import 'package:glutassistantn/pages/setting.dart'; import '../data.dart'; @@ -239,21 +240,57 @@ SnackBar jwSnackBarAction( ); } -SnackBar jwSnackBarActionQ( - bool result, - String text, - BuildContext context, [ - int hideSnackBarSeconds = 2, - ]) { +SnackBar jwSnackBarActionL( + bool result, + String text, + BuildContext context, [ + int hideSnackBarSeconds = 2, +]) { Widget resultIcon = result ? const Icon( - Icons.mood, - color: Colors.green, - ) + Icons.mood, + color: Colors.green, + ) : const Icon( - Icons.mood_bad, - color: Colors.red, + Icons.mood_bad, + color: Colors.red, + ); + return SnackBar( + elevation: 2, + duration: Duration(seconds: hideSnackBarSeconds), + content: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [resultIcon], + ), + behavior: SnackBarBehavior.floating, + action: SnackBarAction( + label: text, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const LoginPage(), + )); + }, + ), ); +} + +SnackBar jwSnackBarActionQ( + bool result, + String text, + BuildContext context, [ + int hideSnackBarSeconds = 2, +]) { + Widget resultIcon = result + ? const Icon( + Icons.mood, + color: Colors.green, + ) + : const Icon( + Icons.mood_bad, + color: Colors.red, + ); return SnackBar( elevation: 2, duration: Duration(seconds: hideSnackBarSeconds), diff --git a/lib/widget/lists.dart b/lib/widget/lists.dart index 6e5d420..beb4c94 100644 --- a/lib/widget/lists.dart +++ b/lib/widget/lists.dart @@ -428,13 +428,13 @@ class QueryScoreState extends State { Container( child: Text( courseLongText2ShortName(queryScore[index][2]), - style: TextStyle(fontSize: 18), + style: TextStyle(fontSize: 16), ), ), Container( child: Text( queryScore[index][3] == "" ? "慕课成绩不会被统计" : queryScore[index][3], - style: TextStyle(color: Colors.black45), + style: TextStyle(color: Colors.black45,fontSize: 12), ), ), ], @@ -451,8 +451,8 @@ class QueryScoreState extends State { ), child: Column(children: [ Text(queryScore[index][4], - style: TextStyle(fontSize: 18, color: Colors.white)), - Text(queryScore[index][5], style: TextStyle(color: Colors.white)), + style: TextStyle(fontSize: 16, color: Colors.white)), + Text(queryScore[index][5], style: TextStyle(color: Colors.white,fontSize: 12)), ]), ), ],