-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #260 from hypha-dao/receive_flow
Receive flow
- Loading branch information
Showing
27 changed files
with
1,586 additions
and
157 deletions.
There are no files selected for viewing
This file contains 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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
File renamed without changes.
This file contains 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,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hypha_wallet/design/hypha_card.dart'; | ||
import 'package:hypha_wallet/design/hypha_colors.dart'; | ||
import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; | ||
import 'package:hypha_wallet/ui/shared/components/text_request_bottom_sheet.dart'; | ||
import 'package:hypha_wallet/ui/shared/ui_constants.dart'; | ||
|
||
class MemoField extends StatelessWidget { | ||
final Function(String? text) onPressed; | ||
final String? memo; | ||
|
||
const MemoField({ | ||
super.key, | ||
this.memo, | ||
required this.onPressed, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
onTap: () { | ||
showModalBottomSheet( | ||
isScrollControlled: true, | ||
clipBehavior: Clip.hardEdge, | ||
context: context, | ||
builder: (modelContext) => FractionallySizedBox( | ||
heightFactor: UIConstants.bottomSheetHeightFraction, | ||
child: TextRequestBottomSheet( | ||
title: 'Enter Memo', | ||
initialText: memo ?? '', | ||
onPressed: onPressed, | ||
), | ||
), | ||
shape: const RoundedRectangleBorder( | ||
borderRadius: BorderRadius.vertical(top: Radius.circular(30)), | ||
), | ||
); | ||
}, | ||
child: HyphaCard( | ||
child: Padding( | ||
padding: const EdgeInsets.all(16), | ||
child: Row( | ||
children: [ | ||
Expanded( | ||
child: Text( | ||
memo ?? 'Memo (optional)', | ||
style: context.hyphaTextTheme.regular.copyWith(color: memo == null ? HyphaColors.midGrey : null), | ||
maxLines: 1, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
), | ||
memo == null ? const SizedBox.shrink() : const Icon(Icons.edit) | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
lib/ui/transfer_tokens/components/number_keyboard_grid.dart
This file contains 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,43 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:hypha_wallet/design/hypha_card.dart'; | ||
import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; | ||
import 'package:hypha_wallet/ui/transfer_tokens/components/keypad_key.dart'; | ||
|
||
class NumberKeyboardGrid extends StatelessWidget { | ||
final ValueChanged<KeypadKey> onKeyTapped; | ||
const NumberKeyboardGrid({super.key, required this.onKeyTapped}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GridView.count( | ||
crossAxisCount: 3, | ||
shrinkWrap: true, | ||
childAspectRatio: 1.8, | ||
physics: const NeverScrollableScrollPhysics(), | ||
children: KeypadKey.values.mapIndexed((index, element) { | ||
final text = switch (element) { | ||
KeypadKey.dot => '.', | ||
KeypadKey.delete => '<-', | ||
_ => element.value.toString(), | ||
}; | ||
return GestureDetector( | ||
onTap: (){ | ||
onKeyTapped(element); | ||
}, | ||
child: Padding( | ||
padding: EdgeInsets.only(top: 8, bottom: 8, left: index % 3 == 0 ? 0 : 8, right: index % 3 == 2 ? 0 : 8), | ||
child: HyphaCard( | ||
borderRadius: BorderRadius.circular(14), | ||
child: Center( | ||
child: Text( | ||
text, | ||
style: context.hyphaTextTheme.mediumTitles, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
}).toList()); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
lib/ui/transfer_tokens/receive/components/receive_view.dart
This file contains 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,89 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:hypha_wallet/design/background/hypha_page_background.dart'; | ||
import 'package:hypha_wallet/design/bottom_component/hypha_safe_bottom_navigation_bar.dart'; | ||
import 'package:hypha_wallet/design/buttons/button_type.dart'; | ||
import 'package:hypha_wallet/design/buttons/hypha_app_button.dart'; | ||
import 'package:hypha_wallet/design/hypha_colors.dart'; | ||
import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; | ||
import 'package:hypha_wallet/ui/transfer_tokens/components/memo_field.dart'; | ||
import 'package:hypha_wallet/ui/transfer_tokens/components/number_keyboard_grid.dart'; | ||
import 'package:hypha_wallet/ui/transfer_tokens/receive/interactor/receive_bloc.dart'; | ||
|
||
class ReceiveView extends StatelessWidget { | ||
const ReceiveView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return HyphaPageBackground( | ||
withGradient: true, | ||
child: Scaffold( | ||
backgroundColor: Colors.transparent, | ||
appBar: AppBar( | ||
title: Text('Receive ${context.read<ReceiveBloc>().state.tokenData.name}'), | ||
), | ||
bottomNavigationBar: BlocBuilder<ReceiveBloc, ReceiveState>( | ||
buildWhen: (p, c) => p.userEnteredAmount != c.userEnteredAmount, | ||
builder: (context, state) { | ||
return HyphaSafeBottomNavigationBar( | ||
child: HyphaAppButton( | ||
onPressed: () { | ||
/// Navigate to receive screen | ||
}, | ||
title: 'Next', | ||
buttonType: ButtonType.primary, | ||
isActive: state.isSubmitEnabled, | ||
), | ||
); | ||
}, | ||
), | ||
body: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 24), | ||
child: Column( | ||
children: [ | ||
BlocBuilder<ReceiveBloc, ReceiveState>( | ||
buildWhen: (p, c) => p.userEnteredAmount != c.userEnteredAmount, | ||
builder: (context, state) { | ||
return Text( | ||
state.userEnteredAmount ?? '0', | ||
textAlign: TextAlign.center, | ||
style: context.hyphaTextTheme.popsExtraLargeAndLight, | ||
); | ||
}, | ||
), | ||
Row( | ||
mainAxisSize: MainAxisSize.min, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text('Amount to ', style: Theme.of(context).textTheme.bodyMedium), | ||
Text( | ||
'receive', | ||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: HyphaColors.primaryBlu), | ||
), | ||
], | ||
), | ||
const SizedBox(height: 24), | ||
BlocBuilder<ReceiveBloc, ReceiveState>( | ||
buildWhen: (c, p) => c.memo != p.memo, | ||
builder: (context, state) { | ||
return MemoField( | ||
onPressed: (value) { | ||
context.read<ReceiveBloc>().add(ReceiveEvent.onMemoEntered(value)); | ||
Get.back(); | ||
}, | ||
memo: state.memo, | ||
); | ||
}, | ||
), | ||
const SizedBox(height: 24), | ||
NumberKeyboardGrid(onKeyTapped: (element) { | ||
context.read<ReceiveBloc>().add(ReceiveEvent.onKeypadTapped(element)); | ||
}), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains 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,6 @@ | ||
part of 'receive_bloc.dart'; | ||
|
||
@freezed | ||
class PageCommand with _$PageCommand { | ||
const factory PageCommand.navigateToSendSuccess(String transactionId) = _NavigateToSendSuccess; | ||
} |
Oops, something went wrong.