chatting/lib/personal_item_page.dart

64 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:chatting/touch_callback.dart';
//个人中心通用组件
//通用列表项
class PersonalItemPage extends StatelessWidget {
//标题
final String title;
//图片路径
final String imagePath;
//图标
final Icon icon;
const PersonalItemPage({Key key, this.title, this.imagePath, this.icon})
: super(key: key);
@override
Widget build(BuildContext context) {
return TouchCallBack(
onPressed: () {
//判断点击的项
switch (title) {
case '好友动态':
//路由到好友动态页面
Navigator.pushNamed(context, '/friends');
break;
case '联系客服':
break;
}
},
//展示部分
child: Container(
height: 50.0,
child: Row(
children: <Widget>[
//图标或图片
Container(
child: imagePath != null
? Image.asset(
imagePath,
width: 32.0,
height: 32.0,
)
: SizedBox(
width: 32.0,
height: 32.0,
child: icon,
),
margin: const EdgeInsets.only(left: 20.0, right: 20.0),
),
Text(
title,
style: TextStyle(fontSize: 16.0, color: Color(0xFF353535)),
)
],
),
),
);
}
}