Skip to content

Commit 85c4947

Browse files
authored
Merge pull request #109 from AndreaDiazCorreia/feat/issue-105
Fix UI improvements in the Create Order screen
2 parents 5a4ab7d + d353d00 commit 85c4947

File tree

4 files changed

+80
-35
lines changed

4 files changed

+80
-35
lines changed

lib/features/order/screens/add_order_screen.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter/services.dart';
23
import 'package:flutter_riverpod/flutter_riverpod.dart';
34
import 'package:go_router/go_router.dart';
45
import 'package:mostro_mobile/data/models/enums/order_type.dart';
@@ -187,8 +188,15 @@ class _AddOrderScreenState extends ConsumerState<AddOrderScreen> {
187188
if (!_marketRate && (value == null || value.isEmpty)) {
188189
return 'Please enter sats amount';
189190
}
191+
if (!_marketRate && !RegExp(r'^[0-9]+$').hasMatch(value!)) {
192+
return 'Please enter numbers only';
193+
}
190194
return null;
191195
},
196+
// Restricting input to numbers only
197+
inputFormatters: [
198+
FilteringTextInputFormatter.digitsOnly,
199+
],
192200
),
193201
),
194202
],

lib/features/order/widgets/form_section.dart

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class FormSection extends StatelessWidget {
77
final Color iconBackgroundColor;
88
final Widget child;
99
final Widget? extraContent;
10+
final String? infoTooltip;
1011

1112
const FormSection({
1213
super.key,
@@ -15,6 +16,7 @@ class FormSection extends StatelessWidget {
1516
required this.iconBackgroundColor,
1617
required this.child,
1718
this.extraContent,
19+
this.infoTooltip,
1820
});
1921

2022
@override
@@ -29,12 +31,69 @@ class FormSection extends StatelessWidget {
2931
children: [
3032
Padding(
3133
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
32-
child: Text(
33-
title,
34-
style: TextStyle(
35-
color: Colors.white.withOpacity(0.7),
36-
fontSize: 14,
37-
),
34+
child: Row(
35+
children: [
36+
Text(
37+
title,
38+
style: TextStyle(
39+
color: Colors.white.withOpacity(0.7),
40+
fontSize: 14,
41+
),
42+
),
43+
if (infoTooltip != null) ...[
44+
const SizedBox(width: 4),
45+
GestureDetector(
46+
onTap: () {
47+
showDialog(
48+
context: context,
49+
builder: (context) => Dialog(
50+
shape: RoundedRectangleBorder(
51+
borderRadius: BorderRadius.circular(12),
52+
),
53+
backgroundColor: const Color(0xFF1E2230),
54+
child: Padding(
55+
padding: const EdgeInsets.all(20.0),
56+
child: Column(
57+
mainAxisSize: MainAxisSize.min,
58+
children: [
59+
Padding(
60+
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 12.0),
61+
child: Text(
62+
infoTooltip!,
63+
style: const TextStyle(color: Colors.white, fontSize: 16, height: 1.4),
64+
textAlign: TextAlign.center,
65+
),
66+
),
67+
const SizedBox(height: 16),
68+
SizedBox(
69+
width: double.infinity,
70+
child: ElevatedButton(
71+
style: ElevatedButton.styleFrom(
72+
backgroundColor: const Color(0xFF8CC63F),
73+
foregroundColor: Colors.black,
74+
shape: RoundedRectangleBorder(
75+
borderRadius: BorderRadius.circular(8),
76+
),
77+
padding: const EdgeInsets.symmetric(vertical: 12),
78+
),
79+
onPressed: () => Navigator.of(context).pop(),
80+
child: const Text('OK', style: TextStyle(fontWeight: FontWeight.bold)),
81+
),
82+
),
83+
],
84+
),
85+
),
86+
),
87+
);
88+
},
89+
child: Icon(
90+
Icons.info_outline,
91+
size: 14,
92+
color: AppTheme.textSubtle,
93+
),
94+
),
95+
],
96+
],
3897
),
3998
),
4099
Container(

lib/features/order/widgets/premium_section.dart

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ class PremiumSection extends StatelessWidget {
1414

1515
@override
1616
Widget build(BuildContext context) {
17-
// Define the premium value display as the icon
17+
// Define the premium value display as the icon - showing only whole numbers
1818
final premiumValueIcon = Text(
19-
value.toStringAsFixed(1),
19+
value.round().toString(),
2020
style: const TextStyle(color: AppTheme.textPrimary, fontSize: 14),
2121
);
2222

@@ -25,6 +25,7 @@ class PremiumSection extends StatelessWidget {
2525
title: 'Premium (%) ',
2626
icon: premiumValueIcon,
2727
iconBackgroundColor: AppTheme.purpleAccent, // Purple color for premium
28+
infoTooltip: 'Adjust how much above or below the market price you want your offer. By default, it\'s set to 0%, with no premium or discount, so if you don\'t want to change the price, you can leave it as is.',
2829
child: Column(
2930
crossAxisAlignment: CrossAxisAlignment.start,
3031
children: [
@@ -64,18 +65,6 @@ class PremiumSection extends StatelessWidget {
6465
),
6566
],
6667
),
67-
// Add an info icon as extra content
68-
extraContent: Padding(
69-
padding: const EdgeInsets.only(right: 16, bottom: 8),
70-
child: Align(
71-
alignment: Alignment.centerRight,
72-
child: Icon(
73-
Icons.info_outline,
74-
size: 14,
75-
color: AppTheme.textSubtle,
76-
),
77-
),
78-
),
7968
);
8069
}
8170
}

lib/features/order/widgets/price_type_section.dart

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ class PriceTypeSection extends StatelessWidget {
2525
title: 'Price type',
2626
icon: priceTypeIcon,
2727
iconBackgroundColor: AppTheme.purpleAccent.withOpacity(0.3), // Purple color consistent with other sections
28+
infoTooltip: '• Select Market Price if you want to use the price that Bitcoin has when someone takes your offer.\n• Select Fixed Price if you want to define the exact amount of Bitcoin you will exchange.',
2829
child: Row(
2930
mainAxisAlignment: MainAxisAlignment.spaceBetween,
3031
children: [
31-
const Text(
32-
'Market price',
33-
style: TextStyle(
32+
Text(
33+
isMarketRate ? 'Market price' : 'Fixed price',
34+
style: const TextStyle(
3435
color: AppTheme.textPrimary, fontWeight: FontWeight.w500),
3536
),
3637
Row(
@@ -53,18 +54,6 @@ class PriceTypeSection extends StatelessWidget {
5354
),
5455
],
5556
),
56-
// Add info icon as extra content
57-
extraContent: Padding(
58-
padding: const EdgeInsets.only(right: 16, bottom: 8),
59-
child: Align(
60-
alignment: Alignment.centerRight,
61-
child: Icon(
62-
Icons.info_outline,
63-
size: 14,
64-
color: AppTheme.textSubtle,
65-
),
66-
),
67-
),
6857
);
6958
}
7059
}

0 commit comments

Comments
 (0)