Skip to content

Commit

Permalink
Add warning banner onto the P2P swap page (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilkris4 authored Jun 2, 2023
1 parent f42e4f6 commit cbf878f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_wid
import 'package:zenon_syrius_wallet_flutter/widgets/modular_widgets/p2p_swap_widgets/p2p_swap_options_button.dart';
import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/dialogs.dart';
import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/error_widget.dart';
import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/important_text_container.dart';
import 'package:zenon_syrius_wallet_flutter/widgets/reusable_widgets/layout_scaffold/card_scaffold.dart';
import 'package:znn_sdk_dart/znn_sdk_dart.dart';

Expand Down Expand Up @@ -124,6 +125,17 @@ class _P2pSwapOptionsCardState extends State<P2pSwapOptionsCard> {
onTap: () => ToastUtils.showToast(context, 'No tutorial yet'),
),
),
const SizedBox(
height: 40.0,
),
const ImportantTextContainer(
text: '''The P2P swap is an experimental feature. '''
'''Please use the feature with caution and only swap small '''
'''amounts. There is absolutely no warranty for this '''
'''software.''',
showBorder: true,
animateBorder: true,
),
],
);
}
Expand Down
98 changes: 66 additions & 32 deletions lib/widgets/reusable_widgets/important_text_container.dart
Original file line number Diff line number Diff line change
@@ -1,53 +1,87 @@
import 'package:flutter/material.dart';
import 'package:zenon_syrius_wallet_flutter/utils/app_colors.dart';

class ImportantTextContainer extends StatelessWidget {
class ImportantTextContainer extends StatefulWidget {
final String text;
final bool showBorder;
final bool animateBorder;
final bool isSelectable;

const ImportantTextContainer({
required this.text,
this.showBorder = false,
this.animateBorder = false,
this.isSelectable = false,
Key? key,
}) : super(key: key);

@override
State<ImportantTextContainer> createState() => _ImportantTextContainerState();
}

class _ImportantTextContainerState extends State<ImportantTextContainer>
with TickerProviderStateMixin {
double _animationValue = 8.0;

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
border: showBorder
? Border.all(
width: 1.0,
color: AppColors.errorColor,
)
: null,
borderRadius: const BorderRadius.all(
Radius.circular(8.0),
),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(15.0, 20.0, 15.0, 20.0),
child: Row(
children: [
const Icon(
Icons.info,
size: 20.0,
color: Colors.white,
),
const SizedBox(
width: 15.0,
return TweenAnimationBuilder<double>(
duration: const Duration(milliseconds: 2500),
tween: Tween(begin: 2.0, end: _animationValue),
curve: Curves.easeInOut,
onEnd: () {
if (widget.animateBorder) {
setState(() {
_animationValue = _animationValue == 8.0 ? 2.0 : 8.0;
});
}
},
builder: (_, double value, __) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
border: widget.showBorder
? Border.all(
width: 1.0,
color: AppColors.errorColor,
)
: null,
boxShadow: widget.showBorder && widget.animateBorder
? [
BoxShadow(
color: AppColors.errorColor.withOpacity(0.35),
blurRadius: value,
spreadRadius: value)
]
: null,
borderRadius: const BorderRadius.all(
Radius.circular(8.0),
),
Expanded(
child: isSelectable
? SelectableText(text, style: const TextStyle(fontSize: 14.0))
: Text(text, style: const TextStyle(fontSize: 14.0)),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(15.0, 20.0, 15.0, 20.0),
child: Row(
children: [
const Icon(
Icons.info,
size: 20.0,
color: Colors.white,
),
const SizedBox(
width: 15.0,
),
Expanded(
child: widget.isSelectable
? SelectableText(widget.text,
style: const TextStyle(fontSize: 14.0))
: Text(widget.text,
style: const TextStyle(fontSize: 14.0)),
),
],
),
],
),
),
),
);
},
);
}
}

0 comments on commit cbf878f

Please sign in to comment.