-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy path51.flutter_advanced_social_media_button.dart
84 lines (77 loc) · 2.74 KB
/
51.flutter_advanced_social_media_button.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:ig_posts/season_2/63.transperant_design_pattern.dart';
import 'package:ig_posts/utils/colors.dart';
import 'package:provider/provider.dart';
class ButtonNotifier extends ChangeNotifier {
bool isExpanded = false;
void toggleButtonExapnsion() {
isExpanded = !isExpanded;
notifyListeners();
}
}
class FlutterSocialMediaButtonView extends StatelessWidget {
const FlutterSocialMediaButtonView({super.key});
@override
Widget build(BuildContext context) {
ButtonNotifier buttonNotifier({required bool renderUI}) =>
Provider.of<ButtonNotifier>(context, listen: renderUI);
showDefaultButton() {
return GestureDetector(
onTap: () {
buttonNotifier(renderUI: false).toggleButtonExapnsion();
},
child: Container(
height: 70,
width: 220,
child: Center(
child: Text("Checkout my socials 🚀",
style: KConstantTextstyles.bold(fontSize: 14))),
decoration: BoxDecoration(
color: KConstantColors.bgColorFaint,
borderRadius: BorderRadius.circular(12)),
),
);
}
showExpandedButton() {
return GestureDetector(
onTap: () {
buttonNotifier(renderUI: false).toggleButtonExapnsion();
},
child: Container(
height: 70,
width: 260,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Icon(FontAwesomeIcons.twitter, color: KConstantColors.whiteColor),
Icon(FontAwesomeIcons.facebook,
color: KConstantColors.whiteColor),
Icon(FontAwesomeIcons.instagram,
color: KConstantColors.whiteColor),
Icon(FontAwesomeIcons.linkedin, color: KConstantColors.whiteColor)
],
)),
decoration: BoxDecoration(
color: KConstantColors.bgColorFaint,
borderRadius: BorderRadius.circular(12)),
),
);
}
return Scaffold(
backgroundColor: KConstantColors.bgColor,
appBar: CustomAppBar(title: "Custom Social Media Button"),
body: Center(
child: AnimatedCrossFade(
secondCurve: Curves.easeInExpo,
firstCurve: Curves.easeInCubic,
firstChild: showDefaultButton(),
secondChild: showExpandedButton(),
crossFadeState: buttonNotifier(renderUI: true).isExpanded
? CrossFadeState.showSecond
: CrossFadeState.showFirst,
duration: Duration(seconds: 1)),
));
}
}