Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
justinenerio committed Sep 12, 2024
1 parent 315b0aa commit 2028ae1
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extension BuildContextExt on BuildContext {
},
minAmount: partner.minimumAmountInDecimal,
currency: Currency.usd,
receiveCurrency: Currency.usdc,
type: type,
calculateEquivalent: (amount) => _calculateReceiveAmount(
amount: amount,
Expand Down Expand Up @@ -182,6 +183,7 @@ window.addEventListener("message", (event) => {
},
minAmount: partner.minimumAmountInDecimal,
currency: Currency.usdc,
receiveCurrency: Currency.usd,
type: type,
calculateEquivalent: (amount) => _calculateReceiveAmount(
amount: amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extension BuildContextExt on BuildContext {
},
minAmount: minAmountNGN,
currency: Currency.ngn,
receiveCurrency: Currency.usdc,
calculateEquivalent: (Amount amount) async => Either.right(
amount.calculateOnRampReceiveAmount(
exchangeRate: rampRate,
Expand Down Expand Up @@ -205,6 +206,7 @@ window.addEventListener("message", (event) => {
},
minAmount: partner.minimumAmountInDecimal,
currency: Currency.usdc,
receiveCurrency: Currency.ngn,
calculateEquivalent: (amount) async => Either.right(
amount.calculateOffRampReceiveAmount(
exchangeRate: rampRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class RampAmountScreen extends StatefulWidget {
required this.calculateFee,
required this.partner,
required this.exchangeRate,
required this.receiveCurrency,
});

static Future<void> push(
Expand All @@ -53,6 +54,7 @@ class RampAmountScreen extends StatefulWidget {
AmountCalculator? calculateEquivalent,
FeeCalculator? calculateFee,
String? exchangeRate,
Currency? receiveCurrency,
}) =>
Navigator.of(context).push<void>(
MaterialPageRoute(
Expand All @@ -65,6 +67,7 @@ class RampAmountScreen extends StatefulWidget {
partner: partner,
calculateFee: calculateFee,
exchangeRate: exchangeRate,
receiveCurrency: receiveCurrency,
),
),
);
Expand All @@ -76,8 +79,8 @@ class RampAmountScreen extends StatefulWidget {
final RampType type;
final RampPartner partner;
final FeeCalculator? calculateFee;

final String? exchangeRate;
final Currency? receiveCurrency;

@override
State<RampAmountScreen> createState() => _RampAmountScreenState();
Expand Down Expand Up @@ -140,6 +143,7 @@ class _RampAmountScreenState extends State<RampAmountScreen> {
calculateEquivalent: widget.calculateEquivalent,
minAmount: widget.minAmount,
type: widget.type,
receiveCurrency: widget.receiveCurrency,
),
),
SizedBox(height: 14.h),
Expand Down Expand Up @@ -203,12 +207,14 @@ class _ReceiveTextField extends StatefulWidget {
required this.calculateEquivalent,
required this.type,
required this.minAmount,
required this.receiveCurrency,
});

final Amount amount;
final AmountCalculator? calculateEquivalent;
final Decimal minAmount;
final RampType type;
final Currency? receiveCurrency;

@override
State<_ReceiveTextField> createState() => _ReceiveTextFieldState();
Expand Down Expand Up @@ -261,7 +267,11 @@ class _ReceiveTextFieldState extends State<_ReceiveTextField>
final label = context.l10n.youReceiveTitle;

if (snapshot.connectionState != ConnectionState.done) {
return LoadingTextField(label: label);
return RampTextField(
label: label,
controller: null,
currency: widget.receiveCurrency,
);
}

final data = snapshot.data;
Expand Down Expand Up @@ -472,8 +482,8 @@ class _InfoRow extends StatelessWidget {
const Spacer(),
if (isLoading)
LoaderAnimation(
height: 16.h,
width: 70.w,
height: 18.h,
width: 95.w,
)
else
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,39 @@ import '../../../ui/colors.dart';
class LoadingTextField extends StatelessWidget {
const LoadingTextField({
super.key,
required this.label,
required this.prefix,
required this.suffix,
});

final String label;
final Widget prefix;
final Widget suffix;

@override
Widget build(BuildContext context) => Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Widget build(BuildContext context) => Container(
margin: null,
decoration: const ShapeDecoration(
color: CpColors.darkBackgroundColor,
shape: StadiumBorder(),
),
padding: EdgeInsets.only(
top: 12.h,
bottom: 12.h,
right: 24.w,
left: 17.w,
),
child: Row(
children: [
Padding(
padding: EdgeInsets.only(left: 16.w, bottom: 4.h),
child: Text(
label,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
prefix,
Expanded(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: LoaderAnimation(
height: 25.h,
width: double.infinity,
),
),
),
SizedBox(height: 2.h),
Container(
margin: null,
decoration: const ShapeDecoration(
color: CpColors.darkBackgroundColor,
shape: StadiumBorder(),
),
padding: EdgeInsets.symmetric(
vertical: 14.h,
horizontal: 18.w,
),
child: Row(
children: [
SizedBox.square(
dimension: 36.w,
child: const CircleAvatar(
backgroundColor: Colors.grey,
),
),
SizedBox(width: 24.w),
Expanded(
child: LoaderAnimation(
height: 30.h,
width: double.infinity,
),
),
SizedBox(width: 24.w),
],
),
),
suffix,
],
),
);
Expand All @@ -76,7 +58,10 @@ class LoaderAnimation extends StatelessWidget {
Widget build(BuildContext context) => SizedBox(
height: height,
width: width,
child: const _ShimmerEffect(),
child: const ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(30)),
child: _ShimmerEffect(),
),
);
}

Expand Down Expand Up @@ -112,12 +97,11 @@ class _ShimmerEffectState extends State<_ShimmerEffect>
builder: (context, child) => Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.grey.withOpacity(0.3),
Colors.grey.withOpacity(0.5),
Colors.grey.withOpacity(0.3),
colors: const [
Color(0xFF2A2A2A),
Color(0xFF3A3A3A),
],
stops: const [0.0, 0.5, 1.0],
stops: const [0.0, 1.0],
begin: Alignment(-1.0 + (2 * _controller.value), 0.0),
end: Alignment(1.0 + (2 * _controller.value), 0.0),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../../../ui/text_field.dart';
import '../../currency/models/currency.dart';
import '../../tokens/token.dart';
import '../../tokens/widgets/token_icon.dart';
import 'ramp_loader.dart';

class RampTextField extends StatelessWidget {
const RampTextField({
Expand All @@ -18,8 +19,8 @@ class RampTextField extends StatelessWidget {
});

final String label;
final Currency currency;
final TextEditingController controller;
final Currency? currency;
final TextEditingController? controller;

@override
Widget build(BuildContext context) {
Expand All @@ -31,16 +32,22 @@ class RampTextField extends StatelessWidget {
width: 36.w,
height: 36.h,
)
: CircleAvatar(
backgroundColor: CpColors.darkBackgroundColor,
child: Assets.icons.money.svg(),
),
: _defaultLogo,
CryptoCurrency(:final Token token) => TokenIcon(
token: token,
size: 36.w,
size: 40.w,
),
_ => _defaultLogo,
};

final symbol = Text(
currency?.symbol ?? '',
style: TextStyle(
fontSize: 34.sp,
fontWeight: FontWeight.w700,
),
);

return Padding(
padding: EdgeInsets.symmetric(horizontal: 24.w),
child: Column(
Expand All @@ -56,35 +63,42 @@ class RampTextField extends StatelessWidget {
),
),
),
CpTextField(
padding: EdgeInsets.symmetric(
vertical: 12.h,
horizontal: 24.w,
),
controller: controller,
inputType: const TextInputType.numberWithOptions(decimal: true),
textInputAction: TextInputAction.next,
textCapitalization: TextCapitalization.none,
backgroundColor: CpColors.darkBackgroundColor,
placeholder: '0',
placeholderColor: Colors.white,
textColor: Colors.white,
fontSize: 34.sp,
fontWeight: FontWeight.w700,
prefix: logo,
suffix: Padding(
padding: EdgeInsets.only(right: 24.w),
child: Text(
currency.symbol,
style: TextStyle(
fontSize: 34.sp,
fontWeight: FontWeight.w700,
),
if (controller == null)
LoadingTextField(
prefix: logo,
suffix: symbol,
)
else
CpTextField(
padding: EdgeInsets.symmetric(
vertical: 12.h,
horizontal: 24.w,
),
controller: controller,
inputType: const TextInputType.numberWithOptions(decimal: true),
textInputAction: TextInputAction.next,
textCapitalization: TextCapitalization.none,
backgroundColor: CpColors.darkBackgroundColor,
placeholder: '0',
placeholderColor: Colors.white,
textColor: Colors.white,
fontSize: 34.sp,
fontWeight: FontWeight.w700,
prefix: logo,
readOnly: true,
suffix: Padding(
padding: EdgeInsets.only(right: 24.w),
child: symbol,
),
),
),
],
),
);
}
}

Widget get _defaultLogo => CircleAvatar(
maxRadius: 20.w,
backgroundColor: CpColors.darkBackgroundColor,
child: Assets.icons.money.svg(),
);
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ final offRampAmountScreenStory = Story(
),
),
exchangeRate: null,
receiveCurrency: null,
),
);

0 comments on commit 2028ae1

Please sign in to comment.