Created
January 24, 2024 14:36
-
-
Save diefferson/8fadd08d9a05addcc3ca37099f4e9c43 to your computer and use it in GitHub Desktop.
MVPA - (Block implementation)
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
import 'package:base/base.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:module_home/res/strings/home_strings.dart'; | |
import 'package:module_home/src/analytics/feedback_events.dart'; | |
import 'feedback_send_suggestion_presenter.dart'; | |
import 'feedback_send_suggestion_actions.dart'; | |
class FeedbackSendSuggestionPage extends StatefulWidget { | |
const FeedbackSendSuggestionPage({ | |
super.key, | |
}); | |
static Future push({required BuildContext context}) { | |
return Navigator.of(context).push( | |
MaterialPageRoute( | |
builder: (_) => const FeedbackSendSuggestionPage(), | |
), | |
); | |
} | |
@override | |
State createState() => _FeedbackSendSuggestionPageState(); | |
} | |
class _FeedbackSendSuggestionPageState | |
extends BaseState<FeedbackSendSuggestionPage, FeedbackSendSuggestionPagePresenter> | |
with FeedbackSendSuggestionPageActions { | |
@override | |
AnalyticsEvent? get analyticsScreenEvent => FeedbackEvents.suggestionScreen(); | |
@override | |
Widget build(BuildContext context) { | |
return NoodleScaffold( | |
title: HomeStrings.of(context).feedback, | |
appBarColor: AppColors.of(context).backgroundLight, | |
backgroundColor: AppColors.of(context).backgroundLight, | |
expandedContent: true, | |
body: _body(), | |
); | |
} | |
Widget _body() { | |
return NoodleInputFieldPage( | |
textAreaHeight: 100, | |
padding: const EdgeInsets.symmetric( | |
horizontal: 24, | |
vertical: 40, | |
), | |
data: NoodleInputFieldData( | |
formInputStyle: FormInputStyle.textarea, | |
actionText: AppStrings.of(context).send, | |
hintText: HomeStrings.of(context).howWeCanImprove, | |
showActionButton: true, | |
disableActionWithEmptyField: true, | |
withBorder: false, | |
onSubmitted: presenter.sendTicket, | |
), | |
); | |
} | |
} |
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
import 'package:base/base.dart'; | |
import 'package:flutter/widgets.dart'; | |
import 'package:module_home/module_home.dart'; | |
import 'package:module_home/src/analytics/feedback_events.dart'; | |
import 'feedback_send_suggestion_presenter.dart'; | |
import 'success/feedback_send_suggestion_success.dart'; | |
mixin FeedbackSendSuggestionPageActions | |
on BaseState<FeedbackSendSuggestionPage, FeedbackSendSuggestionPagePresenter> { | |
Future showError() async { | |
noodleAnalytics.logEvent(FeedbackEvents.errorSendSuggestionOccurred()); | |
NoodleErrorBottomSheet.show( | |
context: context, | |
message: AppStrings.of(context).genericError, | |
); | |
} | |
Future showSuccess() async { | |
noodleAnalytics.logEvent(FeedbackEvents.successSendSuggestionOccurred()); | |
await FeedbackSendSuggestionSuccess.push(context: context); | |
if (mounted) { | |
Navigator.of(context).pop(); | |
} | |
} | |
} |
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
import 'package:base/base.dart'; | |
import 'feedback_send_suggestion_actions.dart'; | |
import 'package:module_home/module_home.dart'; | |
class FeedbackSendSuggestionPagePresenter | |
extends BasePresenter<FeedbackSendSuggestionPageActions> { | |
FeedbackSendSuggestionPagePresenter(this._createTicketUseCase); | |
final SupportCreateTicketUseCase _createTicketUseCase; | |
static const _suggestTag = "suggest"; | |
void sendTicket(String message) { | |
final SupportTicket supportTicket = SupportTicket(_suggestTag, message); | |
_createTicketUseCase | |
.execute( | |
withLoading: true, | |
params: SupportCreateTicketUseCaseParams(supportTicket), | |
) | |
.onSuccess((data) { | |
view.showSuccess(); | |
}).onError((error) { | |
view.showError(); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment