purchase_bottom_bar.dart
3.69 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
import 'purchase_colors.dart';
class PurchaseBottomBar extends StatelessWidget {
const PurchaseBottomBar({
super.key,
required this.label,
required this.loading,
required this.onPressed,
this.onTermsTap,
this.onPrivacyTap,
});
final String label;
final bool loading;
final VoidCallback onPressed;
final VoidCallback? onTermsTap;
final VoidCallback? onPrivacyTap;
@override
Widget build(BuildContext context) {
final bottomInset = MediaQuery.paddingOf(context).bottom;
final buttonWidth = math.min(280.0, MediaQuery.sizeOf(context).width - 74);
return IgnorePointer(
ignoring: loading,
child: Container(
height: 147 + bottomInset,
padding: EdgeInsets.only(bottom: bottomInset),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.center,
colors: [Color(0x00F5F2FF), PurchaseColors.background],
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
width: buttonWidth,
height: 48,
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
elevation: 0,
shadowColor: Colors.transparent,
backgroundColor: PurchaseColors.proYellow,
foregroundColor: PurchaseColors.title,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
textStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: 0,
),
),
child: loading
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(
strokeWidth: 2,
color: PurchaseColors.title,
),
)
: Text(label),
),
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_BottomLink(
label: context.l10n.purchaseTermsOfService,
onTap: onTermsTap,
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Text(
'|',
style: TextStyle(
color: PurchaseColors.subtitle,
fontSize: 12,
),
),
),
_BottomLink(
label: context.l10n.purchasePrivacyPolicy,
onTap: onPrivacyTap,
),
],
),
const SizedBox(height: 18),
],
),
),
);
}
}
class _BottomLink extends StatelessWidget {
const _BottomLink({required this.label, required this.onTap});
final String label;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
behavior: HitTestBehavior.opaque,
child: Text(
label,
style: const TextStyle(
color: PurchaseColors.subtitle,
fontSize: 12,
height: 1.2,
),
),
);
}
}