Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mobile-app/lib/features/components/link_text.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:resonance_network_wallet/features/styles/app_text_theme.dart';
import 'package:url_launcher/url_launcher.dart';

class LinkText extends StatelessWidget {
final String label;
final String url;
final TextStyle? textStyle;

const LinkText({super.key, required this.label, required this.url, this.textStyle});

@override
Widget build(BuildContext context) {
final effectiveTextStyle = (textStyle ?? context.themeText.paragraph)?.copyWith(
decoration: TextDecoration.underline,
);

return GestureDetector(
child: Text(label, style: effectiveTextStyle),
onTap: () {
final Uri uri = Uri.parse(url);
launchUrl(uri);
},
);
}
}
40 changes: 40 additions & 0 deletions mobile-app/lib/features/components/list_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:resonance_network_wallet/features/styles/app_colors_theme.dart';
import 'package:resonance_network_wallet/features/styles/app_size_theme.dart';
import 'package:resonance_network_wallet/features/styles/app_text_theme.dart';
import 'package:resonance_network_wallet/shared/extensions/media_query_data_extension.dart';

class ListItem extends StatelessWidget {
final String title;
final VoidCallback onTap;
final Widget? trailing;
final bool showArrow;

const ListItem({super.key, required this.title, required this.onTap, this.trailing, this.showArrow = true});

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: context.isTablet ? 16 : 12, horizontal: 18),
decoration: ShapeDecoration(
color: context.themeColors.buttonGlass,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(title, style: context.themeText.smallParagraph),
trailing ??
(showArrow
? Icon(Icons.arrow_forward_ios, size: context.themeSize.settingMenuIconSize)
: const SizedBox()),
],
),
),
);
}
}
235 changes: 235 additions & 0 deletions mobile-app/lib/features/components/raid_submission_action_sheet.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/features/components/button.dart';
import 'package:resonance_network_wallet/features/components/custom_text_field.dart';
import 'package:resonance_network_wallet/features/styles/app_colors_theme.dart';
import 'package:resonance_network_wallet/features/styles/app_size_theme.dart';
import 'package:resonance_network_wallet/features/styles/app_text_theme.dart';
import 'package:resonance_network_wallet/providers/raider_quest_providers.dart';
import 'package:resonance_network_wallet/shared/extensions/media_query_data_extension.dart';
import 'package:resonance_network_wallet/shared/extensions/snackbar_extensions.dart';
import 'package:resonance_network_wallet/utils/validators.dart';

class RaidSubmissionActionSheet extends ConsumerStatefulWidget {
const RaidSubmissionActionSheet({super.key});

@override
ConsumerState<RaidSubmissionActionSheet> createState() => _RaidSubmissionActionSheetState();
}

class _RaidSubmissionActionSheetState extends ConsumerState<RaidSubmissionActionSheet> {
final _taskmasterService = TaskmasterService();

final _targetTweetController = TextEditingController();
final _replyTweetController = TextEditingController();

bool _isSubmitting = false;
bool _isDisabled = true;

String? _targetErrorMsg;
String? _replyErrorMsg;
String? _errorMsg;

@override
void initState() {
super.initState();

_targetTweetController.addListener(_checkFormValidity);
_replyTweetController.addListener(_checkFormValidity);
}

void _checkFormValidity() {
String targetInput = _targetTweetController.text.trim();
String replyInput = _replyTweetController.text.trim();

bool targetTweetIsValid = Validators.isValidXStatusUrl(targetInput);
bool replyTweetIsValid = Validators.isValidXStatusUrl(replyInput);

String errMsg = 'Invalid X status link.';

setState(() {
_isDisabled = !targetTweetIsValid || !replyTweetIsValid;
_errorMsg = null;
_targetErrorMsg = targetTweetIsValid ? null : errMsg;
_replyErrorMsg = replyTweetIsValid ? null : errMsg;
});
}

void _closeSheet() {
Navigator.of(context).pop();
}

Future<void> _handleSubmit(String targetLink, String replyLink) async {
setState(() {
_isSubmitting = true;
});

try {
await _taskmasterService.addRaidSubmission(targetLink, replyLink);
if (mounted) {
context.showSuccessSnackbar(title: 'Success submitted!', message: 'Success adding raid submission!');
}
ref.invalidate(raiderSubmissionsProvider);
_closeSheet();
} catch (e) {
print('Failed adding raid submission: $e');

setState(() {
_isSubmitting = false;
_errorMsg = e.toString();
});
}
}

@override
Widget build(BuildContext context) {
final height = MediaQuery.of(context).size.height;

final effectiveHeight = height * 0.76;
final effectiveRadius = 5.0;
final effectivePadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 16);

return SafeArea(
child: Container(
height: effectiveHeight,
padding: effectivePadding,
decoration: ShapeDecoration(
color: Colors.black,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(effectiveRadius)),
),
child: _buildForm(context),
),
);
}

Widget _buildForm(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.infinity,
padding: const EdgeInsets.all(7),
decoration: ShapeDecoration(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(100))),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: _isSubmitting ? null : _closeSheet,
child: Icon(Icons.close, size: context.isTablet ? 28 : 24),
),
],
),
),
const SizedBox(height: 22),
Text('Raid Submission', style: context.themeText.mediumTitle?.copyWith(fontWeight: FontWeight.w600)),
SizedBox(height: context.isTablet ? 32 : 24),
Text(
'Have you conducted a raid on a target? Enter your raid detail here:',
style: context.themeText.smallParagraph?.copyWith(color: context.themeColors.inputLabel),
),
const SizedBox(height: 12),
CustomTextField(
controller: _targetTweetController,
labelText: 'Target Tweet Link',
fillColor: context.themeColors.background,
trailing: InkWell(
onTap: () async {
final data = await Clipboard.getData('text/plain');
if (data != null && data.text != null) {
_targetTweetController.text = data.text!;
}
},
child: SvgPicture.asset('assets/paste_icon_1.svg', width: context.isTablet ? 24 : 18),
),
errorMsg: _targetErrorMsg,
),
const SizedBox(height: 8),
CustomTextField(
controller: _replyTweetController,
labelText: 'Reply Tweet Link',
fillColor: context.themeColors.background,
trailing: InkWell(
onTap: () async {
final data = await Clipboard.getData('text/plain');
if (data != null && data.text != null) {
_replyTweetController.text = data.text!;
}
},
child: SvgPicture.asset('assets/paste_icon_1.svg', width: context.isTablet ? 24 : 18),
),
errorMsg: _replyErrorMsg,
),
const SizedBox(height: 24),
const Spacer(),
if (_errorMsg != null)
Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(_errorMsg!, style: context.themeText.detail?.copyWith(color: context.themeColors.textError)),
const SizedBox(height: 4),
],
),
),
SizedBox(
width: context.isTablet ? 465 : null,
child: Button(
label: 'Submit',
isLoading: _isSubmitting,
isDisabled: _isDisabled,
variant: ButtonVariant.primary,
onPressed: () {
_handleSubmit(_targetTweetController.text, _replyTweetController.text);
},
),
),

SizedBox(height: context.themeSize.bottomButtonSpacing),
],
);
}
}

void showRaidSubmissionActionSheet(
BuildContext context, {
String? referralCode,
bool? directlyShowRewardProgram,
bool showRewardProgram = true,
}) {
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width),
builder: (context) => Stack(
children: [
Positioned.fill(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.black, const Color(0xFF312E6E).useOpacity(0.4), Colors.black],
),
),
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
child: Container(color: Colors.black.useOpacity(0.3), child: const RaidSubmissionActionSheet()),
),
),
],
),
);
}
2 changes: 1 addition & 1 deletion mobile-app/lib/features/main/screens/navbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:quantus_sdk/quantus_sdk.dart';
import 'package:resonance_network_wallet/features/components/referral_and_reward_action_sheet.dart';
import 'package:resonance_network_wallet/features/main/screens/quests_screen.dart';
import 'package:resonance_network_wallet/features/main/screens/quests/quests_screen.dart';
import 'package:resonance_network_wallet/features/main/screens/settings_screen.dart';
import 'package:resonance_network_wallet/features/main/screens/transactions_screen.dart';
import 'package:resonance_network_wallet/features/main/screens/wallet_main/wallet_main.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:resonance_network_wallet/features/components/wallet_app_bar.dart
import 'package:resonance_network_wallet/features/styles/app_colors_theme.dart';
import 'package:resonance_network_wallet/features/styles/app_text_theme.dart';
import 'package:resonance_network_wallet/providers/account_associations_providers.dart';
import 'package:resonance_network_wallet/providers/raider_quest_providers.dart';
import 'package:resonance_network_wallet/shared/extensions/clipboard_extensions.dart';
import 'package:resonance_network_wallet/shared/extensions/media_query_data_extension.dart';
import 'package:resonance_network_wallet/shared/extensions/snackbar_extensions.dart';
Expand Down Expand Up @@ -134,6 +135,7 @@ class _AccountAssociationsScreenState extends ConsumerState<AccountAssociationsS

case AppLifecycleState.resumed:
ref.invalidate(accountAssociationsProvider);
ref.invalidate(raiderSubmissionsProvider);
break;
}
}
Expand Down
Loading