Skip to content

Commit

Permalink
query增加成绩查询是否登录判断
Browse files Browse the repository at this point in the history
  • Loading branch information
nano71 committed Nov 14, 2021
1 parent b6a146c commit a364b39
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 55 deletions.
93 changes: 53 additions & 40 deletions lib/pages/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<QueryPage> createState() => _QueryPageState();
Expand All @@ -29,8 +30,6 @@ class _QueryPageState extends State<QueryPage> {
}

_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();
Expand Down Expand Up @@ -88,7 +87,20 @@ class _QueryPageState extends State<QueryPage> {
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
Expand All @@ -112,13 +124,9 @@ class _QueryPageState extends State<QueryPage> {
),
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(
Expand All @@ -143,6 +151,9 @@ class _QueryPageState extends State<QueryPage> {
});
},
),
SizedBox(
width: 25,
),
DropdownButton(
iconEnabledColor: Colors.white,
isDense: true,
Expand Down Expand Up @@ -170,7 +181,11 @@ class _QueryPageState extends State<QueryPage> {
_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),
Expand All @@ -179,35 +194,33 @@ class _QueryPageState extends State<QueryPage> {
})
],
),
],
),
),
),
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),
)
],
)
],
),
Expand Down
59 changes: 48 additions & 11 deletions lib/widget/bars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: <Widget>[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),
Expand Down
8 changes: 4 additions & 4 deletions lib/widget/lists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,13 @@ class QueryScoreState extends State<QueryScore> {
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),
),
),
],
Expand All @@ -451,8 +451,8 @@ class QueryScoreState extends State<QueryScore> {
),
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)),
]),
),
],
Expand Down

0 comments on commit a364b39

Please sign in to comment.