增加登陆页面
parent
20975951ba
commit
3eac96e2d2
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,8 +8,11 @@ enum MessageType { SYSTEM, PUBLIC, CHAT, GROUP }
|
|||
// 聊天数据
|
||||
class MessageData {
|
||||
|
||||
//id
|
||||
int id;
|
||||
//发送者的id
|
||||
int sendId;
|
||||
|
||||
//接受者的id
|
||||
int toId;
|
||||
|
||||
//头像
|
||||
String avatar;
|
||||
|
|
@ -26,13 +29,16 @@ class MessageData {
|
|||
//消息类型
|
||||
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 = [
|
||||
new MessageData("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("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("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(12,3,"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(3,12,"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),
|
||||
];
|
||||
|
|
@ -106,7 +106,6 @@ class _ChattingDetailsState extends State<ChattingDetails> with TickerProviderSt
|
|||
onPressed: _isComposing ? () => _handleSubmitted(_textEditingController.text) : null
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:chatting/chatting_data_page.dart';
|
||||
|
||||
|
|
@ -22,15 +23,9 @@ class ChatMessagePage extends StatefulWidget {
|
|||
|
||||
class _ChatMessagePageState extends State<ChatMessagePage> {
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
if(widget.messageData.title==null){
|
||||
print("11");
|
||||
|
||||
}
|
||||
|
||||
return SizeTransition(
|
||||
sizeFactor: CurvedAnimation(
|
||||
parent: widget.animationController,
|
||||
|
|
@ -42,29 +37,62 @@ class _ChatMessagePageState extends State<ChatMessagePage> {
|
|||
}
|
||||
|
||||
Widget cellContaint (BuildContext context){
|
||||
var sendId = widget.messageData.sendId;
|
||||
var toId = widget.messageData.toId;
|
||||
var currentId = 12;
|
||||
if(sendId == currentId){
|
||||
print(sendId);
|
||||
return Container(
|
||||
padding:const EdgeInsets.fromLTRB(300.0,0.0,10,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,),
|
||||
)
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}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,),
|
||||
)
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
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),
|
||||
)
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ class _LoadingPageState extends State<LoadingPage> {
|
|||
//加载页默认停留三秒
|
||||
Future.delayed(Duration(seconds: 3),(){
|
||||
print("仿微信app页面正在加载中");
|
||||
Navigator.of(context).pushReplacementNamed("app");
|
||||
//判断是否登录,如果没有登陆则跳转至登录页,如果登录则跳转至聊天页
|
||||
Navigator.of(context).pushReplacementNamed("login");
|
||||
//Navigator.of(context).pushReplacementNamed("app");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:chatting/loading_page.dart';
|
||||
import 'package:chatting/app_page.dart';
|
||||
import 'package:chatting/login_page.dart';
|
||||
|
||||
void main(){
|
||||
return runApp(MyApp());
|
||||
|
|
@ -18,7 +19,10 @@ class MyApp extends StatelessWidget {
|
|||
routes: <String,WidgetBuilder>{
|
||||
'app' : (BuildContext context){
|
||||
return new App();
|
||||
}
|
||||
},
|
||||
'login' : (BuildContext context){
|
||||
return new LoginPag();
|
||||
},
|
||||
},
|
||||
//指定首页,默认为加载页
|
||||
home: LoadingPage(),
|
||||
|
|
|
|||
21
pubspec.lock
21
pubspec.lock
|
|
@ -50,6 +50,13 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -71,6 +78,13 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
dio:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dio
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.17"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
|
@ -88,6 +102,13 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.3.11"
|
||||
fluttertoast:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fluttertoast
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ dependencies:
|
|||
cupertino_icons: ^0.1.3
|
||||
flutter_webview_plugin: ^0.3.4
|
||||
date_format: ^1.0.4
|
||||
dio: ^1.0.9
|
||||
fluttertoast: ^3.0.3
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
@ -68,7 +71,10 @@ flutter:
|
|||
- assets/images/ic_new_friend.png
|
||||
- assets/images/ic_label.png
|
||||
- assets/images/ic_group.png
|
||||
- assets/images/ic_username.png
|
||||
- assets/images/ic_password.png
|
||||
- assets/images/icon_right.png
|
||||
- assets/images/jspang.png
|
||||
|
||||
fonts:
|
||||
- family: appIconFonts
|
||||
|
|
|
|||
Loading…
Reference in New Issue