ui: Migrate AddContactPage to Redux

This commit is contained in:
2021-12-24 20:33:04 +01:00
parent 3396a36b47
commit a88ceb7897
7 changed files with 150 additions and 108 deletions

View File

@@ -0,0 +1,5 @@
class AddContactAction {
final String jid;
AddContactAction({ required this.jid });
}

View File

@@ -0,0 +1,10 @@
import "package:moxxyv2/ui/pages/addcontact/state.dart";
import "package:moxxyv2/redux/addcontact/actions.dart";
AddContactPageState addContactPageReducer(AddContactPageState state, dynamic action) {
if (action is AddContactAction) {
return state.copyWith(doingWork: true);
}
return state;
}

View File

@@ -2,8 +2,10 @@ import "dart:collection";
import "package:moxxyv2/redux/conversation/reducers.dart";
import "package:moxxyv2/redux/conversations/reducers.dart";
import "package:moxxyv2/redux/login/reducers.dart";
import "package:moxxyv2/redux/addcontact/reducers.dart";
import "package:moxxyv2/ui/pages/login/state.dart";
import "package:moxxyv2/ui/pages/conversation/state.dart";
import "package:moxxyv2/ui/pages/addcontact/state.dart";
import "package:moxxyv2/models/message.dart";
import "package:moxxyv2/models/conversation.dart";
@@ -12,7 +14,8 @@ MoxxyState moxxyReducer(MoxxyState state, dynamic action) {
messages: messageReducer(state.messages, action),
conversations: conversationReducer(state.conversations, action),
loginPageState: loginReducer(state.loginPageState, action),
conversationPageState: conversationPageReducer(state.conversationPageState, action)
conversationPageState: conversationPageReducer(state.conversationPageState, action),
addContactPageState: addContactPageReducer(state.addContactPageState, action)
);
}
@@ -21,7 +24,8 @@ class MoxxyState {
final List<Conversation> conversations;
final LoginPageState loginPageState;
final ConversationPageState conversationPageState;
final AddContactPageState addContactPageState;
const MoxxyState({ required this.messages, required this.conversations, required this.loginPageState, required this.conversationPageState });
MoxxyState.initialState() : messages = HashMap(), conversations = List.empty(growable: true), loginPageState = LoginPageState(doingWork: false, showPassword: false), conversationPageState = ConversationPageState(showSendButton: false);
const MoxxyState({ required this.messages, required this.conversations, required this.loginPageState, required this.conversationPageState, required this.addContactPageState });
MoxxyState.initialState() : messages = HashMap(), conversations = List.empty(growable: true), loginPageState = LoginPageState(doingWork: false, showPassword: false), conversationPageState = ConversationPageState(showSendButton: false), addContactPageState = AddContactPageState(doingWork: false);
}