|
- import 'package:chat/data/constants.dart';
- import 'package:flutter/material.dart';
-
- class LoveToggle extends StatefulWidget {
-
-
- final bool isActive;
-
- final void Function(bool) onTap;
-
- LoveToggle({
- Key key,
- this.onTap,
- this.isActive: false,
- }) : super(key: key);
-
- @override
- _LoveToggleState createState() => _LoveToggleState();
- }
-
- class _LoveToggleState extends State<LoveToggle> {
- bool isActive;
-
- @override
- void initState() {
- super.initState();
- isActive = widget.isActive;
- }
-
- @override
- Widget build(BuildContext context) {
- // Color curColor = isActive ? widget.activeColor : widget.defaultColor;
- // IconData curIcon = isActive ? widget.activeIcon : widget.icon;
- return InkWell(
- child: Container(
- width: 100,
- height: 30,
- decoration: BoxDecoration(color: isActive?Color(0xffFF69B3):Colors.transparent,border: Border.all(color: Color(0xFF878787), width: 1),borderRadius: BorderRadius.circular(16)) ,
- padding: EdgeInsets.only(
- left: 15, right: 15, bottom: 5,top: 5 ),
- child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
- Icon(
- IconData(
- 0xe625,
- fontFamily: Constants.IconFontFamily,
- ),
- size: 15,
- color: isActive?Colors.white:Color(0xffB2B2B2),
- ),
- SizedBox(width: 5,),
- Text('LOVE',style: TextStyle(color: isActive?Colors.white:Color(0xffB2B2B2)),)
- ],)),
- onTap: () {
- setState(() {
- isActive = !isActive;
- widget.onTap(isActive);
- });
- },
- );
- }
- }
|