|
- import 'package:chat/data/constants.dart';
- import 'package:chat/generated/i18n.dart';
- import 'package:flutter/material.dart';
-
- class UserChips extends StatelessWidget {
- final String city; //城市
- final int age; //年龄
- final String constellation; //星座
- final String professional; //职业
- final Color bgColor;
- final TextStyle fontStyle;
- final bool isCenter;
- const UserChips(
- {Key key,
- this.city,
- this.age,
- this.constellation,
- this.professional,
- this.bgColor,
- this.fontStyle,
- this.isCenter: false})
- : super(key: key);
-
- Widget _buildChip(str) {
- return Container(
- margin: EdgeInsets.only(bottom: 5, right: 5),
- padding: EdgeInsets.symmetric(horizontal: 10, vertical: 3),
- decoration: BoxDecoration(
- color: bgColor == null ? Constants.LightBlueBackgroundColor : bgColor,
- borderRadius: BorderRadius.circular(15.0),
- ),
- child: Text(
- str,
- textScaleFactor: 1.0,
- style: fontStyle == null
- ? TextStyle(
- fontSize: 11,
- color: Constants.LightBlueTextColor,
- )
- : fontStyle,
- textAlign: TextAlign.center,
- ),
- );
- }
-
- @override
- Widget build(BuildContext context) {
- return Wrap(
- alignment: isCenter ? WrapAlignment.center : WrapAlignment.start,
- crossAxisAlignment: WrapCrossAlignment.center,
- children: <Widget>[
- _buildChip(city),
- _buildChip(professional),
- _buildChip('$age ${I18n.of(context).years_old}-$constellation'),
- ],
- );
- }
- }
|