-
Notifications
You must be signed in to change notification settings - Fork 23
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 #2544 from get10101/feat/on-boarding-dialog
Fund channel flow
- Loading branch information
Showing
36 changed files
with
2,039 additions
and
187 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get_10101/common/color.dart'; | ||
import 'package:get_10101/common/domain/model.dart'; | ||
import 'package:get_10101/features/wallet/application/util.dart'; | ||
|
||
class BitcoinBalanceField extends StatelessWidget { | ||
final Amount bitcoinBalance; | ||
final double? fontSize; | ||
|
||
const BitcoinBalanceField({super.key, required this.bitcoinBalance, this.fontSize = 28.0}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var (leading, balance) = getFormattedBalance(bitcoinBalance.toInt); | ||
|
||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text(leading, | ||
style: TextStyle( | ||
color: Colors.grey, | ||
fontSize: fontSize, | ||
fontWeight: FontWeight.bold, | ||
)), | ||
Text(balance, | ||
style: TextStyle( | ||
color: Colors.black87, | ||
fontSize: fontSize, | ||
fontWeight: FontWeight.bold, | ||
)), | ||
Icon(Icons.currency_bitcoin, size: fontSize, color: tenTenOnePurple), | ||
], | ||
); | ||
} | ||
} |
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:flutter/material.dart'; | ||
import 'package:qr_flutter/qr_flutter.dart'; | ||
|
||
class CustomQrCode extends StatelessWidget { | ||
final String data; | ||
final ImageProvider embeddedImage; | ||
final double embeddedImageSizeWidth; | ||
final double embeddedImageSizeHeight; | ||
final double dimension; | ||
|
||
const CustomQrCode({ | ||
Key? key, | ||
required this.data, | ||
required this.embeddedImage, | ||
this.dimension = 350.0, | ||
this.embeddedImageSizeHeight = 50, | ||
this.embeddedImageSizeWidth = 50, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox.square( | ||
dimension: dimension, | ||
child: QrImageView( | ||
data: data, | ||
eyeStyle: const QrEyeStyle( | ||
eyeShape: QrEyeShape.square, | ||
color: Colors.black, | ||
), | ||
dataModuleStyle: const QrDataModuleStyle( | ||
dataModuleShape: QrDataModuleShape.square, | ||
color: Colors.black, | ||
), | ||
embeddedImage: embeddedImage, | ||
embeddedImageStyle: QrEmbeddedImageStyle( | ||
size: Size(embeddedImageSizeHeight, embeddedImageSizeWidth), | ||
), | ||
version: QrVersions.auto, | ||
padding: const EdgeInsets.all(5), | ||
), | ||
); | ||
} | ||
} |
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,48 @@ | ||
import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge; | ||
|
||
enum FundingChannelTaskStatus { | ||
pending, | ||
funded, | ||
orderCreated, | ||
failed; | ||
|
||
static (FundingChannelTaskStatus, String?) fromApi(dynamic taskStatus) { | ||
if (taskStatus is bridge.FundingChannelTask_Pending) { | ||
return (FundingChannelTaskStatus.pending, null); | ||
} | ||
|
||
if (taskStatus is bridge.FundingChannelTask_Funded) { | ||
return (FundingChannelTaskStatus.funded, null); | ||
} | ||
|
||
if (taskStatus is bridge.FundingChannelTask_Failed) { | ||
final error = taskStatus.field0; | ||
return (FundingChannelTaskStatus.failed, error); | ||
} | ||
|
||
if (taskStatus is bridge.FundingChannelTask_OrderCreated) { | ||
final orderId = taskStatus.field0; | ||
return (FundingChannelTaskStatus.orderCreated, orderId); | ||
} | ||
|
||
return (FundingChannelTaskStatus.pending, null); | ||
} | ||
|
||
static bridge.FundingChannelTask apiDummy() { | ||
return const bridge.FundingChannelTask_Pending(); | ||
} | ||
|
||
@override | ||
String toString() { | ||
switch (this) { | ||
case FundingChannelTaskStatus.pending: | ||
return "Pending"; | ||
case FundingChannelTaskStatus.failed: | ||
return "Failed"; | ||
case FundingChannelTaskStatus.funded: | ||
return "Funded"; | ||
case FundingChannelTaskStatus.orderCreated: | ||
return "OrderCreated"; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
mobile/lib/common/funding_channel_task_change_notifier.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,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get_10101/common/application/event_service.dart'; | ||
import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge; | ||
import 'package:get_10101/common/domain/funding_channel_task.dart'; | ||
import 'package:get_10101/logger/logger.dart'; | ||
|
||
class FundingChannelChangeNotifier extends ChangeNotifier implements Subscriber { | ||
FundingChannelTaskStatus? status; | ||
String? error; | ||
|
||
@override | ||
void notify(bridge.Event event) async { | ||
if (event is bridge.Event_FundingChannelNotification) { | ||
logger.d("Received a funding channel task notification. ${event.field0}"); | ||
var fromApi = FundingChannelTaskStatus.fromApi(event.field0); | ||
status = fromApi.$1; | ||
error = fromApi.$2; | ||
notifyListeners(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.