Loading...
Searching...
No Matches
follow_me_button.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'widget_styles.dart';
3import 'follow_me_button_config.dart';
4
18class FollowMeButton extends StatelessWidget {
20 final bool isFollowing;
22 final void Function() onPressed;
24 final FollowMeButtonConfig config;
25
27 Key? key,
28 required this.isFollowing,
29 required this.onPressed,
31 }) : super(key: key);
32
33 @override
34 Widget build(BuildContext context) {
35 final safePadding = MediaQuery.of(context).padding;
36 final padding = config.padding ?? EdgeInsets.only(
37 right: kStandardRightPadding + safePadding.right,
38 bottom: kFollowMeBottomPadding + safePadding.bottom,
39 );
40 final width = config.buttonWidth ?? kStandardButtonWidth;
41 final height = config.buttonHeight ?? kStandardButtonHeight;
42 final bgColor = config.buttonBackgroundColor ?? kButtonBackgroundColor;
43 final accentColor = config.accentColor ?? kBaseBlueColor;
44 final textColor = config.textColor ?? kBaseBlackColor;
45
46 Widget iconChild = config.followMeIcon ?? Image.asset(
47 'packages/navigine_sdk/assets/navigine_follow_me.png',
48 width: 32,
49 height: 32,
50 fit: BoxFit.contain,
51 );
52 if (isFollowing && config.followMeIconActive != null) {
53 iconChild = config.followMeIconActive!;
54 }
55
56 return Align(
57 alignment: Alignment.bottomRight,
58 child: Padding(
59 padding: padding,
60 child: Container(
61 width: width,
62 height: height,
63 decoration: BoxDecoration(
64 color: isFollowing ? kWhiteBackgroundColor : bgColor,
65 borderRadius: kStandardBorderRadius,
66 border: isFollowing
67 ? Border.all(
68 color: kBorderColor,
69 width: kActiveBorderWidth,
70 )
71 : null,
72 boxShadow: kStandardShadows,
73 ),
74 child: Material(
75 color: Colors.transparent,
76 child: InkWell(
77 borderRadius: kStandardBorderRadius,
78 onTap: onPressed,
79 child: Padding(
80 padding: const EdgeInsets.all(8.0),
81 child: (config.followMeIcon != null || config.followMeIconActive != null)
82 ? iconChild
83 : ColorFiltered(
84 colorFilter: ColorFilter.mode(
85 isFollowing ? accentColor : textColor,
86 BlendMode.srcIn,
87 ),
88 child: iconChild,
89 ),
90 ),
91 ),
92 ),
93 ),
94 ),
95 );
96 }
97}