Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 line
1.7 KiB

  1. import 'package:chat/data/constants.dart';
  2. import 'package:flutter/material.dart';
  3. class LoveToggle extends StatefulWidget {
  4. final bool isActive;
  5. final void Function(bool) onTap;
  6. LoveToggle({
  7. Key key,
  8. this.onTap,
  9. this.isActive: false,
  10. }) : super(key: key);
  11. @override
  12. _LoveToggleState createState() => _LoveToggleState();
  13. }
  14. class _LoveToggleState extends State<LoveToggle> {
  15. bool isActive;
  16. @override
  17. void initState() {
  18. super.initState();
  19. isActive = widget.isActive;
  20. }
  21. @override
  22. Widget build(BuildContext context) {
  23. // Color curColor = isActive ? widget.activeColor : widget.defaultColor;
  24. // IconData curIcon = isActive ? widget.activeIcon : widget.icon;
  25. return InkWell(
  26. child: Container(
  27. width: 100,
  28. height: 30,
  29. decoration: BoxDecoration(color: isActive?Color(0xffFF69B3):Colors.transparent,border: Border.all(color: Color(0xFF878787), width: 1),borderRadius: BorderRadius.circular(16)) ,
  30. padding: EdgeInsets.only(
  31. left: 15, right: 15, bottom: 5,top: 5 ),
  32. child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
  33. Icon(
  34. IconData(
  35. 0xe625,
  36. fontFamily: Constants.IconFontFamily,
  37. ),
  38. size: 15,
  39. color: isActive?Colors.white:Color(0xffB2B2B2),
  40. ),
  41. SizedBox(width: 5,),
  42. Text('LOVE',style: TextStyle(color: isActive?Colors.white:Color(0xffB2B2B2)),)
  43. ],)),
  44. onTap: () {
  45. setState(() {
  46. isActive = !isActive;
  47. widget.onTap(isActive);
  48. });
  49. },
  50. );
  51. }
  52. }