-
Notifications
You must be signed in to change notification settings - Fork 1
Swap button feature flag #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d1de8d5
new accounts list
n13 535d699
Merge branch 'main' into accounts_list_v3
n13 d4fdaf0
share button fix on account edit
n13 406c6b0
new edit account screen
n13 68dd3ce
restore v1 accounts screen, move new code to accounts sheet
n13 8930670
format
n13 2a4e31c
rename to accounts sheet
n13 f74c45d
color cleanup
n13 7aafb36
accounts screen buttons
n13 9a12d48
format
n13 ba7df5b
reversible coming soon
n13 85d4914
hide balance
n13 d47361c
explorer button is a glass button
n13 0b55cb3
hide info button
n13 2573947
comment out reversible code
n13 82a0ad2
swap screen updated
n13 ac3e005
swap screen flag
n13 d55c0c6
toast fix and receive screen copy buttons
n13 150bc09
format
n13 28b57d3
update scanner screen to spec
n13 004ff9d
format and linter
n13 5bd4930
Merge branch 'main' into swap_button_feature_flag
n13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:image_picker/image_picker.dart'; | ||
| import 'package:mobile_scanner/mobile_scanner.dart'; | ||
| import 'package:resonance_network_wallet/v2/components/glass_container.dart'; | ||
| import 'package:resonance_network_wallet/v2/theme/app_colors.dart'; | ||
| import 'package:resonance_network_wallet/v2/theme/app_text_styles.dart'; | ||
|
|
||
| class QrScannerPage extends StatefulWidget { | ||
| const QrScannerPage({super.key}); | ||
|
|
||
| @override | ||
| State<QrScannerPage> createState() => _QrScannerPageState(); | ||
| } | ||
|
|
||
| class _QrScannerPageState extends State<QrScannerPage> { | ||
| final _controller = MobileScannerController(); | ||
| bool _scanned = false; | ||
|
|
||
| @override | ||
| void dispose() { | ||
| _controller.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
| void _onDetect(BarcodeCapture capture) { | ||
| if (_scanned) return; | ||
| final code = capture.barcodes.firstOrNull?.rawValue; | ||
| if (code != null && code.isNotEmpty) { | ||
| _scanned = true; | ||
| Navigator.pop(context, code); | ||
| } | ||
| } | ||
|
|
||
| Future<void> _pickImage() async { | ||
| final image = await ImagePicker().pickImage(source: ImageSource.gallery); | ||
| if (image == null || !mounted) return; | ||
| final capture = await _controller.analyzeImage(image.path); | ||
| if (!mounted) return; | ||
| if (capture != null) { | ||
| _onDetect(capture); | ||
| } else { | ||
| ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('No QR code found in image'))); | ||
| } | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final colors = context.colors; | ||
| final text = context.themeText; | ||
| final screen = MediaQuery.of(context).size; | ||
| final frameSize = (screen.width - 112).clamp(220.0, 280.0); | ||
|
|
||
| return Scaffold( | ||
| backgroundColor: Colors.black, | ||
| body: Stack( | ||
| children: [ | ||
| MobileScanner(controller: _controller, onDetect: _onDetect), | ||
| CustomPaint( | ||
| size: Size(screen.width, screen.height), | ||
| painter: _OverlayPainter(frameSize: frameSize, screenSize: screen), | ||
| ), | ||
| Center(child: _ScanFrame(size: frameSize)), | ||
| Positioned( | ||
| left: 0, | ||
| right: 0, | ||
| top: screen.height / 2 + frameSize / 2 + 24, | ||
| child: Row( | ||
| mainAxisAlignment: MainAxisAlignment.center, | ||
| children: [ | ||
| _actionButton(icon: Icons.image_outlined, onTap: _pickImage, colors: colors), | ||
| const SizedBox(width: 8), | ||
| ValueListenableBuilder<MobileScannerState>( | ||
| valueListenable: _controller, | ||
| builder: (_, state, _) { | ||
| final isOn = state.torchState == TorchState.on; | ||
| return _actionButton( | ||
| icon: isOn ? Icons.flash_on : Icons.flash_off, | ||
| onTap: _controller.toggleTorch, | ||
| colors: colors, | ||
| ); | ||
| }, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| Positioned( | ||
| bottom: 58, | ||
| left: 24, | ||
| right: 24, | ||
| child: GestureDetector( | ||
| onTap: () => Navigator.pop(context), | ||
| child: GlassContainer( | ||
| asset: GlassContainer.wideAsset, | ||
| child: Text( | ||
| 'Cancel', | ||
| textAlign: TextAlign.center, | ||
| style: text.paragraph?.copyWith(color: colors.textPrimary, fontWeight: FontWeight.w500), | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| Widget _actionButton({required IconData icon, required VoidCallback onTap, required AppColorsV2 colors}) { | ||
| return GestureDetector( | ||
| onTap: onTap, | ||
| child: Container( | ||
| width: 40, | ||
| height: 40, | ||
| decoration: BoxDecoration(color: Colors.white.withValues(alpha: 0.1), borderRadius: BorderRadius.circular(8)), | ||
| child: Icon(icon, size: 20, color: colors.textPrimary), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _OverlayPainter extends CustomPainter { | ||
| final double frameSize; | ||
| final Size screenSize; | ||
|
|
||
| _OverlayPainter({required this.frameSize, required this.screenSize}); | ||
|
|
||
| @override | ||
| void paint(Canvas canvas, Size size) { | ||
| final rect = Offset.zero & size; | ||
| final frameRect = Rect.fromCenter( | ||
| center: Offset(size.width / 2, size.height / 2), | ||
| width: frameSize, | ||
| height: frameSize, | ||
| ); | ||
| final path = Path() | ||
| ..addRect(rect) | ||
| ..addRRect(RRect.fromRectAndRadius(frameRect, const Radius.circular(16))); | ||
| path.fillType = PathFillType.evenOdd; | ||
| canvas.drawPath(path, Paint()..color = Colors.black.withValues(alpha: 0.6)); | ||
| } | ||
|
|
||
| @override | ||
| bool shouldRepaint(_OverlayPainter old) => frameSize != old.frameSize; | ||
| } | ||
|
|
||
| class _ScanFrame extends StatelessWidget { | ||
| final double size; | ||
| const _ScanFrame({required this.size}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final color = Colors.white.withValues(alpha: 0.92); | ||
| return SizedBox( | ||
| width: size, | ||
| height: size, | ||
| child: Stack( | ||
| children: [ | ||
| _corner(top: true, left: true, color: color), | ||
| _corner(top: true, left: false, color: color), | ||
| _corner(top: false, left: true, color: color), | ||
| _corner(top: false, left: false, color: color), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| Widget _corner({required bool top, required bool left, required Color color}) { | ||
| return Positioned( | ||
| top: top ? 0 : null, | ||
| bottom: top ? null : 0, | ||
| left: left ? 0 : null, | ||
| right: left ? null : 0, | ||
| child: SizedBox( | ||
| width: 41, | ||
| height: 41, | ||
| child: DecoratedBox( | ||
| decoration: BoxDecoration( | ||
| borderRadius: BorderRadius.only( | ||
| topLeft: top && left ? const Radius.circular(16) : Radius.zero, | ||
| topRight: top && !left ? const Radius.circular(16) : Radius.zero, | ||
| bottomLeft: !top && left ? const Radius.circular(16) : Radius.zero, | ||
| bottomRight: !top && !left ? const Radius.circular(16) : Radius.zero, | ||
| ), | ||
| border: Border( | ||
| top: top ? BorderSide(color: color, width: 1.6) : BorderSide.none, | ||
| bottom: !top ? BorderSide(color: color, width: 1.6) : BorderSide.none, | ||
| left: left ? BorderSide(color: color, width: 1.6) : BorderSide.none, | ||
| right: !left ? BorderSide(color: color, width: 1.6) : BorderSide.none, | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to be persistent? this persistent is when the snackbar will not be closed unless it timeout the duration or user swipe it away. If user tap on screen it will not close it. Just want to make sure we wanted this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually that's not what persistent means
It's still going away after 2 seconds I tried it
Persistent is needed so it works when there's an action sheet
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh okay, I thought persistent so it's not Dismissible by tap