ui: Migrate AddContactPage to Redux
This commit is contained in:
5
lib/redux/addcontact/actions.dart
Normal file
5
lib/redux/addcontact/actions.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddContactAction {
|
||||
final String jid;
|
||||
|
||||
AddContactAction({ required this.jid });
|
||||
}
|
||||
10
lib/redux/addcontact/reducers.dart
Normal file
10
lib/redux/addcontact/reducers.dart
Normal 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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user