增加登陆页面

master
zhangmeng1334717033 2020-06-09 17:35:43 +08:00
parent 20975951ba
commit 3eac96e2d2
12 changed files with 378 additions and 39 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
assets/images/jspang.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

28
lib/chatting_api.dart Normal file
View File

@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
Dio dio = new Dio();
class ChattingApi{
//
getContactList(String id) async {
var result = await dio.get('http://www.liulongbin.top:3005/api/v2/movie/subject/$id');
return result.data;
}
//
getChattingList(String id) async {
var result = await dio.get('');
return result.data;
}
//
getCurrentUserInfo(String id) async {
var result = await dio.get('');
return result.data;
}
}

View File

@ -8,8 +8,11 @@ enum MessageType { SYSTEM, PUBLIC, CHAT, GROUP }
// //
class MessageData { class MessageData {
//id //id
int id; int sendId;
//id
int toId;
// //
String avatar; String avatar;
@ -26,13 +29,16 @@ class MessageData {
// //
MessageType type; MessageType type;
MessageData(this.avatar, this.title, this.subTitle, this.time, this.type); MessageData(this.sendId, this.toId, this.avatar, this.title, this.subTitle,
this.time, this.type);
} }
List<MessageData> messageData = [ List<MessageData> messageData = [
new MessageData("http://blogimages.jspang.com/blogtouxiang1.jpg", "张三", "一哥", new DateTime.now(), MessageType.CHAT), new MessageData(12,1,"http://blogimages.jspang.com/blogtouxiang1.jpg", "张三", "一哥", new DateTime.now(), MessageType.CHAT),
new MessageData("http://blogimages.jspang.com/blogtouxiang1.jpg", "李四", "一哥", new DateTime.now(), MessageType.CHAT), new MessageData(12,3,"http://blogimages.jspang.com/blogtouxiang1.jpg", "李四", "一哥", new DateTime.now(), MessageType.CHAT),
new MessageData("http://blogimages.jspang.com/blogtouxiang1.jpg", "王麻子", "一哥", new DateTime.now(), MessageType.CHAT), new MessageData(1,12,"http://blogimages.jspang.com/blogtouxiang1.jpg", "王麻子", "一哥", new DateTime.now(), MessageType.CHAT),
new MessageData("http://blogimages.jspang.com/blogtouxiang1.jpg", "王五", "一哥", new DateTime.now(), MessageType.CHAT), new MessageData(3,12,"http://blogimages.jspang.com/blogtouxiang1.jpg", "王五", "一哥", new DateTime.now(), MessageType.CHAT),
new MessageData("http://blogimages.jspang.com/blogtouxiang1.jpg", "赵柳", "一哥", new DateTime.now(), MessageType.CHAT), new MessageData(1,3,"http://blogimages.jspang.com/blogtouxiang1.jpg", "赵柳", "一哥", new DateTime.now(), MessageType.CHAT),
]; ];

View File

@ -106,7 +106,6 @@ class _ChattingDetailsState extends State<ChattingDetails> with TickerProviderSt
onPressed: _isComposing ? () => _handleSubmitted(_textEditingController.text) : null onPressed: _isComposing ? () => _handleSubmitted(_textEditingController.text) : null
), ),
) )
], ],
), ),
), ),

View File

@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:chatting/chatting_data_page.dart'; import 'package:chatting/chatting_data_page.dart';
@ -22,15 +23,9 @@ class ChatMessagePage extends StatefulWidget {
class _ChatMessagePageState extends State<ChatMessagePage> { class _ChatMessagePageState extends State<ChatMessagePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if(widget.messageData.title==null){
print("11");
}
return SizeTransition( return SizeTransition(
sizeFactor: CurvedAnimation( sizeFactor: CurvedAnimation(
parent: widget.animationController, parent: widget.animationController,
@ -42,10 +37,16 @@ class _ChatMessagePageState extends State<ChatMessagePage> {
} }
Widget cellContaint (BuildContext context){ Widget cellContaint (BuildContext context){
var sendId = widget.messageData.sendId;
var toId = widget.messageData.toId;
var currentId = 12;
if(sendId == currentId){
print(sendId);
return Container( return Container(
padding:const EdgeInsets.fromLTRB(300.0,0.0,10,0.0),
margin: const EdgeInsets.symmetric(vertical: 10.0), margin: const EdgeInsets.symmetric(vertical: 10.0),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
new Container( new Container(
@ -58,7 +59,32 @@ class _ChatMessagePageState extends State<ChatMessagePage> {
new Text(widget.messageData.title, style: Theme.of(context).textTheme.subhead), new Text(widget.messageData.title, style: Theme.of(context).textTheme.subhead),
new Container( new Container(
margin: const EdgeInsets.only(top: 5.0), margin: const EdgeInsets.only(top: 5.0),
child: new Text(widget.text), child: new Text(widget.text, textAlign: TextAlign.right,),
)
]
)
],
),
);
}else{
return Container(
padding:const EdgeInsets.fromLTRB(0.0,0.0,0.0,0.0),
margin: const EdgeInsets.symmetric(vertical: 10.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
margin: const EdgeInsets.only(right: 16.0),
child: new CircleAvatar(child: new Text(widget.messageData.title[0])),
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(widget.messageData.title, style: Theme.of(context).textTheme.subhead),
new Container(
margin: const EdgeInsets.only(top: 5.0),
child: new Text(widget.text, textAlign: TextAlign.right,),
) )
] ]
) )
@ -66,6 +92,8 @@ class _ChatMessagePageState extends State<ChatMessagePage> {
), ),
); );
} }
}
} }

View File

@ -16,7 +16,9 @@ class _LoadingPageState extends State<LoadingPage> {
// //
Future.delayed(Duration(seconds: 3),(){ Future.delayed(Duration(seconds: 3),(){
print("仿微信app页面正在加载中"); print("仿微信app页面正在加载中");
Navigator.of(context).pushReplacementNamed("app"); //,,
Navigator.of(context).pushReplacementNamed("login");
//Navigator.of(context).pushReplacementNamed("app");
}); });
} }

245
lib/login_page.dart Normal file
View File

@ -0,0 +1,245 @@
import 'package:date_format/date_format.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
class LoginPag extends StatefulWidget {
@override
_LoginPagState createState() => _LoginPagState();
}
class _LoginPagState extends State<LoginPag> {
TextEditingController _pwdEditController;
TextEditingController _userNameEditController;
final FocusNode _userNameFocusNode = FocusNode();
final FocusNode _pwdFocusNode = FocusNode();
@override
void initState() {
super.initState();
_pwdEditController = TextEditingController();
_userNameEditController = TextEditingController();
_pwdEditController.addListener(() => setState(() => {}));
_userNameEditController.addListener(() => setState(() => {}));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(''),
centerTitle: true,
backgroundColor: Colors.blue[400],
elevation: 0,
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
buildTopWidget(context),
SizedBox(
height: 80,
),
buildEditWidget(context),
buildLoginButton()
],
),
),
);
}
///
Widget buildTopWidget(BuildContext context) {
double height = 200.0;
double width = MediaQuery.of(context).size.width;
print(width);
return Container(
width: width,
height: height,
color: Colors.blue[400],
child: Stack(
overflow: Overflow.visible, //
children: <Widget>[
Positioned(
left: (width - 90) / 2.0,
top: height - 45,
child: Container(
width: 90.0,
height: 90.0,
decoration: BoxDecoration(
///
boxShadow: [
BoxShadow(color: Theme.of(context).cardColor, blurRadius: 4.0)
],
///
shape: BoxShape.circle,
///
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
'https://upload.jianshu.io/users/upload_avatars/2416132/dd23e2841509.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96/format/webp'),
),
),
),
)
],
),
);
}
Widget buildEditWidget(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 15, right: 15),
child: Column(
children: <Widget>[
buildLoginNameTextField(),
SizedBox(height: 20.0),
buildPwdTextField(),
],
),
);
}
Widget buildLoginNameTextField() {
return Container(
height: 40,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.all(Radius.circular(20.0)),
),
child: Stack(
children: <Widget>[
Positioned(
left: 16,
top: 11,
width: 18,
height: 18,
child: Image.asset('assets/images/ic_username.png'),
),
Positioned(
left: 45,
top: 10,
bottom: 10,
width: 1,
child: Container(
color: Colors.black,
),
),
Positioned(
left: 55,
right: 10,
top: 10,
height: 30,
child: TextField(
controller: _userNameEditController,
focusNode: _userNameFocusNode,
decoration: InputDecoration(
hintText: "请输入用户名",
border: InputBorder.none,
),
style: TextStyle(fontSize: 14),
),
)
],
),
);
}
Widget buildPwdTextField() {
return Container(
height: 40,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.all(Radius.circular(20.0)),
),
child: Stack(
children: <Widget>[
Positioned(
left: 16,
top: 11,
width: 18,
height: 18,
child: Image.asset('assets/images/ic_password.png'),
),
Positioned(
left: 45,
top: 10,
bottom: 10,
width: 1,
child: Container(
color: Colors.black,
),
),
Positioned(
left: 55,
right: 10,
top: 10,
height: 30,
child: TextField(
controller: _pwdEditController,
focusNode: _pwdFocusNode,
decoration: InputDecoration(
hintText: "请输入密码",
border: InputBorder.none,
),
style: TextStyle(fontSize: 14),
obscureText: true,
///
),
)
],
));
}
Widget buildLoginButton() {
return Container(
margin: EdgeInsets.only(top: 40, left: 10, right: 10),
padding: EdgeInsets.all(0),
width: MediaQuery.of(context).size.width - 20,
height: 40,
child: RaisedButton(
onPressed: () {
if (checkInput()) {
Fluttertoast.showToast(
msg: "登录成功",
gravity: ToastGravity.CENTER,
timeInSecForIos: 2,
textColor: Colors.white,
fontSize: 14.0);
}
},
child: Text("登录"),
color: Colors.blue[400],
textColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
),
),
);
}
bool checkInput() {
if (_userNameEditController.text.length == 0) {
Fluttertoast.showToast(
msg: "请输入用户名",
gravity: ToastGravity.CENTER,
timeInSecForIos: 2,
textColor: Colors.white,
fontSize: 14.0);
return false;
} else if (_pwdEditController.text.length == 0) {
Fluttertoast.showToast(
msg: "请输入密码",
gravity: ToastGravity.CENTER,
timeInSecForIos: 2,
textColor: Colors.white,
fontSize: 14.0);
return false;
}
return true;
}
}

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:chatting/loading_page.dart'; import 'package:chatting/loading_page.dart';
import 'package:chatting/app_page.dart'; import 'package:chatting/app_page.dart';
import 'package:chatting/login_page.dart';
void main(){ void main(){
return runApp(MyApp()); return runApp(MyApp());
@ -18,7 +19,10 @@ class MyApp extends StatelessWidget {
routes: <String,WidgetBuilder>{ routes: <String,WidgetBuilder>{
'app' : (BuildContext context){ 'app' : (BuildContext context){
return new App(); return new App();
} },
'login' : (BuildContext context){
return new LoginPag();
},
}, },
//, //,
home: LoadingPage(), home: LoadingPage(),

View File

@ -50,6 +50,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
cookie_jar:
dependency: transitive
description:
name: cookie_jar
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.8"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -71,6 +78,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.8" version: "1.0.8"
dio:
dependency: "direct main"
description:
name: dio
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.17"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -88,6 +102,13 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.3.11" version: "0.3.11"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.3"
image: image:
dependency: transitive dependency: transitive
description: description:

View File

@ -30,6 +30,9 @@ dependencies:
cupertino_icons: ^0.1.3 cupertino_icons: ^0.1.3
flutter_webview_plugin: ^0.3.4 flutter_webview_plugin: ^0.3.4
date_format: ^1.0.4 date_format: ^1.0.4
dio: ^1.0.9
fluttertoast: ^3.0.3
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
@ -68,7 +71,10 @@ flutter:
- assets/images/ic_new_friend.png - assets/images/ic_new_friend.png
- assets/images/ic_label.png - assets/images/ic_label.png
- assets/images/ic_group.png - assets/images/ic_group.png
- assets/images/ic_username.png
- assets/images/ic_password.png
- assets/images/icon_right.png - assets/images/icon_right.png
- assets/images/jspang.png
fonts: fonts:
- family: appIconFonts - family: appIconFonts