This commit is contained in:
lx
2026-07-06 14:01:11 -04:00
commit c4f97d729d
16468 changed files with 935321 additions and 0 deletions
@@ -0,0 +1,66 @@
local Modules = script.Parent.Parent.Parent
local Components = Modules.Components
local BaseScreen = require(Modules.Views.Phone.BaseScreen)
local Create = require(Modules.Create)
local AlertModel = require(Modules.Models.Alert)
local DialogComponents = require(Components.DialogComponents)
local DeleteAlert = require(Modules.Actions.DeleteAlert)
local Alert = BaseScreen:Template()
function Alert.new(appState, route)
local self = {
appState = appState,
route = route,
alerts = {},
}
setmetatable(self, {__index = Alert})
self.rbx = Create.new"Frame" {
Size = UDim2.new(1, 0, 1, 0),
BackgroundTransparency = 1,
}
self.alertDialog = DialogComponents.AlertDialog.new(appState, nil, nil)
self.alertDialog.rbx.Parent = self.rbx
self.alerts = nil
self.alert = nil
self.alertDialog.accepted.Event:Connect(function()
if self.alert ~= nil then
self.appState.store:dispatch(DeleteAlert(self.alert))
end
end)
self.appState.store.changed:connect(function(current, previous)
if current ~= previous then
self:Update(current.ChatAppReducer.AppState.alerts)
end
end)
return self
end
function Alert:Update(alerts)
if alerts and alerts ~= self.alerts then
if #(alerts.keys) >= 1 then
local alertId = alerts.keys[1]
local alert = alerts.values[alertId]
if alert.type == AlertModel.AlertType.DIALOG then
self.alertDialog:Update(alert)
self.alertDialog:Prompt()
else
warn("Unhandled AlertType")
end
self.alert = alert
end
self.alerts = alerts
end
end
return Alert
@@ -0,0 +1,35 @@
--[[
Defines a set of tweens and default lifecycle handlers appropriate for this
platform.
]]
local BaseScreen = {}
function BaseScreen:Get(...)
return self.new(...)
end
function BaseScreen:Template()
local class = {}
for key, value in pairs(self) do
class[key] = value
end
return class
end
function BaseScreen:Start()
end
function BaseScreen:Stop()
end
function BaseScreen:Resume()
end
function BaseScreen:Pause()
end
function BaseScreen:Destruct()
end
return BaseScreen
@@ -0,0 +1,109 @@
local LuaChat = script.Parent.Parent.Parent
local BaseScreen = require(script.Parent.BaseScreen)
local Components = LuaChat.Components
local ConversationComponent = require(Components.Conversation)
local DialogInfo = require(LuaChat.DialogInfo)
local PopRoute = require(LuaChat.Actions.PopRoute)
local SetRoute = require(LuaChat.Actions.SetRoute)
local Intent = DialogInfo.Intent
local ConversationView = BaseScreen:Template()
ConversationView.__index = ConversationView
ConversationView.viewCache = {}
function ConversationView:Get(appState, route)
if self.viewCache[route.parameters.conversationId] then
return self.viewCache[route.parameters.conversationId]
end
local view = self.new(appState, route)
self.viewCache[route.parameters.conversationId] = view
return view
end
function ConversationView.new(appState, route)
local self = {}
self.route = route
self.conversationId = route.parameters.conversationId
self.appState = appState
self.connections = {}
setmetatable(self, ConversationView)
self.conversationComponent = ConversationComponent.new(appState)
self.rbx = self.conversationComponent.rbx
return self
end
function ConversationView:Start()
BaseScreen.Start(self)
local backButtonConnection = self.conversationComponent.BackButtonPressed:connect(function()
self.appState.store:dispatch(PopRoute())
end)
table.insert(self.connections, backButtonConnection)
local groupDetailConnection = self.conversationComponent.GroupDetailsButtonPressed:connect(function()
self.appState.store:dispatch(SetRoute(
Intent.GroupDetail,
{
conversationId = self.conversationId,
}
))
end)
table.insert(self.connections, groupDetailConnection)
do
local connection = self.appState.store.changed:connect(function(state, oldState)
local conversation = state.ChatAppReducer.Conversations[self.conversationId]
if not conversation then
if self.appState.screenManager:GetCurrentView() == self then
self.appState.store:dispatch(SetRoute(
nil,
{},
Intent.ConversationHub
))
end
self:Stop()
self.viewCache[self.conversationId] = nil
return
end
self.conversationComponent:Update(state, oldState)
end)
table.insert(self.connections, connection)
end
self.conversationComponent:Start()
end
function ConversationView:Stop()
BaseScreen.Stop(self)
self.conversationComponent:Stop()
for _, connection in ipairs(self.connections) do
connection:disconnect()
end
self.connections = {}
end
function ConversationView:Pause()
BaseScreen.Pause(self)
self.conversationComponent:Pause()
end
function ConversationView:Resume()
BaseScreen.Resume(self)
self.conversationComponent:Resume()
end
return ConversationView
@@ -0,0 +1,99 @@
local UserInputService = game:GetService("UserInputService")
local Modules = game:GetService("CoreGui").RobloxGui.Modules
local LuaApp = Modules.LuaApp
local LuaChat = Modules.LuaChat
local BaseScreen = require(LuaChat.Views.Phone.BaseScreen)
local Create = require(LuaChat.Create)
local ConversationHubComponent = require(LuaChat.Components.ConversationHub)
local DialogInfo = require(LuaChat.DialogInfo)
local Constants = require(LuaChat.Constants)
local ConversationActions = require(LuaChat.Actions.ConversationActions)
local SetRoute = require(LuaChat.Actions.SetRoute)
local SetTabBarVisible = require(LuaApp.Actions.SetTabBarVisible)
local Intent = DialogInfo.Intent
local ConversationHub = BaseScreen:Template()
ConversationHub.__index = ConversationHub
function ConversationHub.new(appState, route)
local self = {}
setmetatable(self, ConversationHub)
self.appState = appState
self.route = route
self.ConversationHubComponent = ConversationHubComponent.new(appState)
self.rbx = self.ConversationHubComponent.rbx
local spacer = Create.new "Frame" {
Name = "Spacer",
Size = UDim2.new(1, 0, 0, UserInputService.BottomBarSize.Y),
BackgroundColor3 = Constants.Color.WHITE,
BorderColor3 = Constants.Color.WHITE,
BackgroundTransparency = 0,
LayoutOrder = 3,
}
spacer.Parent = self.rbx
self.ConversationHubComponent.ConversationTapped:connect(function(convoId)
if self.appState.screenManager:GetCurrentView() ~= self then
return
end
local conversation = self.appState.store:getState().ChatAppReducer.Conversations[convoId]
if conversation == nil then
return
end
if conversation.serverState == Constants.ServerState.NONE then
self.appState.store:dispatch(ConversationActions.StartOneToOneConversation(conversation, function(id)
self.appState.store:dispatch(SetRoute(Intent.Conversation, {conversationId = id}))
end))
else
self.appState.store:dispatch(SetRoute(Intent.Conversation, {conversationId = convoId}))
end
end)
self.ConversationHubComponent.CreateChatButtonPressed:connect(function()
self.appState.store:dispatch(SetRoute(Intent.CreateChat, {}))
end)
return self
end
function ConversationHub:Start()
BaseScreen.Start(self)
self.ConversationHubComponent:Start()
self.appState.store:dispatch(SetTabBarVisible(true))
end
function ConversationHub:Stop()
BaseScreen.Stop(self)
self.ConversationHubComponent:Stop()
self.appState.store:dispatch(SetTabBarVisible(false))
end
function ConversationHub:Resume()
BaseScreen.Resume(self)
self.appState.store:dispatch(SetTabBarVisible(true))
end
function ConversationHub:Pause()
BaseScreen.Pause(self)
self.appState.store:dispatch(SetTabBarVisible(false))
end
function ConversationHub:Update(state, oldState)
self.ConversationHubComponent:Update(state, oldState)
end
return ConversationHub
@@ -0,0 +1,81 @@
local Modules = script.Parent.Parent.Parent
local Components = Modules.Components
local Constants = require(Modules.Constants)
local BaseScreen = require(Modules.Views.Phone.BaseScreen)
local EditChatGroupComponent = require(Components.EditChatGroup)
local DialogInfo = require(Modules.DialogInfo)
local Intent = DialogInfo.Intent
local PopRoute = require(Modules.Actions.PopRoute)
local SetRoute = require(Modules.Actions.SetRoute)
local EditChatGroup = BaseScreen:Template()
EditChatGroup.__index = EditChatGroup
function EditChatGroup.new(appState, route)
local self = {
appState = appState,
route = route,
convoId = route.parameters.conversationId,
connections = {},
}
setmetatable(self, EditChatGroup)
local participantCount = #appState.store:getState().ChatAppReducer.Conversations[self.convoId].participants
local maxSize = Constants.MAX_PARTICIPANT_COUNT + 1 - participantCount
self.editChatGroupComponent = EditChatGroupComponent.new(appState, maxSize, self.convoId)
self.rbx = self.editChatGroupComponent.rbx
local backButtonConnection = self.editChatGroupComponent.BackButtonPressed:connect(function()
self.appState.store:dispatch(PopRoute())
end)
table.insert(self.connections, backButtonConnection)
return self
end
function EditChatGroup:Start()
BaseScreen.Start(self)
do
local connection = self.appState.store.changed:connect(function(current, previous)
local currentConversationId = current.ChatAppReducer.Location.current.parameters.conversationId
local conversation = current.ChatAppReducer.Conversations[currentConversationId]
if current ~= previous and conversation then
self:Update(current, previous)
else
if self.appState.screenManager:GetCurrentView() == self then
self.appState.store:dispatch(SetRoute(nil, {}, Intent.ConversationHub))
end
end
self:Update(current, previous)
end)
table.insert(self.connections, connection)
end
end
function EditChatGroup:Stop()
for _, connection in ipairs(self.connections) do
connection:disconnect()
end
self.connections = {}
BaseScreen.Stop(self)
end
function EditChatGroup:Destruct()
self.editChatGroupComponent:Destruct()
self.editChatGroupComponent = nil
BaseScreen.Destruct(self)
end
function EditChatGroup:Update(current, previous)
self.editChatGroupComponent:Update(current, previous)
end
return EditChatGroup
@@ -0,0 +1,66 @@
local Modules = game:GetService("CoreGui").RobloxGui.Modules
local LuaApp = Modules.LuaApp
local LuaChat = Modules.LuaChat
local BaseScreen = require(LuaChat.Views.Phone.BaseScreen)
local Create = require(LuaChat.Create)
local Constants = require(LuaChat.Constants)
local GameShareComponent = require(LuaChat.Components.GameShareComponent)
local SetTabBarVisible = require(LuaApp.Actions.SetTabBarVisible)
local GameShareView = BaseScreen:Template()
GameShareView.__index = GameShareView
function GameShareView.new(appState, route)
local self = {}
self.appState = appState
self.route = route
setmetatable(self, GameShareView)
local innerFrame = Create.new"Frame" {
Name = "InnerFrame",
Size = UDim2.new(1, 0, 1, 0),
Position = UDim2.new(0.5, 0, 0, 0),
AnchorPoint = Vector2.new(0.5, 0),
BackgroundColor3 = Constants.Color.GRAY5,
BackgroundTransparency = 1,
BorderSizePixel = 0,
LayoutOrder = 2,
Create.new("UIListLayout") {
Name = "ListLayout",
SortOrder = Enum.SortOrder.LayoutOrder,
},
}
self.gameShareComponent = GameShareComponent.new(appState, route.parameters.placeId, innerFrame)
self.rbx = self.gameShareComponent.rbx
return self
end
function GameShareView:Start()
self.gameShareComponent:Start()
self.prevTabBarVisibility = self.appState.store:getState().TabBarVisible
BaseScreen.Start(self)
self.appState.store:dispatch(SetTabBarVisible(false))
end
function GameShareView:Stop()
self.gameShareComponent:Stop()
BaseScreen.Stop(self)
self.appState.store:dispatch(SetTabBarVisible(self.prevTabBarVisibility))
end
function GameShareView:Destruct()
self.gameShareComponent:Destruct()
BaseScreen.Destruct(self)
end
return GameShareView
@@ -0,0 +1,118 @@
local Modules = game:GetService("CoreGui").RobloxGui.Modules
local LuaChat = Modules.LuaChat
local BaseScreen = require(LuaChat.Views.Phone.BaseScreen)
local Constants = require(LuaChat.Constants)
local ToastModel = require(LuaChat.Models.ToastModel)
local DialogInfo = require(LuaChat.DialogInfo)
local GroupDetailComponent = require(LuaChat.Components.GroupDetail)
local PopRoute = require(LuaChat.Actions.PopRoute)
local SetRoute = require(LuaChat.Actions.SetRoute)
local ShowToast = require(LuaChat.Actions.ShowToast)
local Intent = DialogInfo.Intent
local GroupDetail = BaseScreen:Template()
GroupDetail.__index = GroupDetail
function GroupDetail.new(appState, route)
local self = {}
self.appState = appState
self.route = route
self.groupDetailComponent = GroupDetailComponent.new(appState, route.parameters.conversationId)
self.rbx = self.groupDetailComponent.rbx
self.connections = {}
setmetatable(self, GroupDetail)
local backButtonConnection = self.groupDetailComponent.BackButtonPressed:connect(function()
self.appState.store:dispatch(PopRoute())
end)
table.insert(self.connections, backButtonConnection)
local addFriendsConnection = self.groupDetailComponent.AddFriendsPressed:connect(function()
if self.appState.screenManager:GetCurrentView() ~= self then
return
end
local participantCount = #self.groupDetailComponent.conversation.participants
if participantCount >= Constants.MAX_PARTICIPANT_COUNT + 1 then
local messageKey = "Feature.Chat.Message.ToastText"
local messageArguments = {
friendNum = tostring(Constants.MAX_PARTICIPANT_COUNT+1),
}
local toastModel = ToastModel.new(Constants.ToastIDs.TOO_MANY_PEOPLE, messageKey, messageArguments)
self.appState.store:dispatch(ShowToast(toastModel))
else
self.appState.store:dispatch(SetRoute(Intent.EditChatGroup, {
conversationId = self.groupDetailComponent.conversation.id
}))
end
end)
table.insert(self.connections, addFriendsConnection)
return self
end
function GroupDetail:Start()
BaseScreen.Start(self)
do
local connection = self.appState.store.changed:connect(function(current, previous)
local currentConversationId = current.ChatAppReducer.Location.current.parameters.conversationId
local conversation = current.ChatAppReducer.Conversations[currentConversationId]
if current ~= previous and conversation then
self.groupDetailComponent:Update(current, previous)
else
if self.appState.screenManager:GetCurrentView() == self then
self.appState.store:dispatch(SetRoute(nil, {}, Intent.ConversationHub))
end
end
end)
table.insert(self.connections, connection)
end
end
-- GroupDetail does not need to slide off-screen when spawning Dialogs.
function GroupDetail:Pause()
local state = self.appState.store:getState()
local dialogType = DialogInfo.GetTypeBasedOnIntent(
self.appState.store:getState().FormFactor,
state.ChatAppReducer.Location.current.intent
)
if dialogType == DialogInfo.DialogType.Popup then
self.isNextPageGenericDialog = true
else
self.isNextPageGenericDialog = false
BaseScreen.Pause(self)
end
end
function GroupDetail:Resume()
if self.isNextPageGenericDialog == nil or self.isNextPageGenericDialog == false then
BaseScreen.Resume(self)
end
self.isNextPageGenericDialog = false
end
function GroupDetail:Stop()
BaseScreen.Stop(self)
for _, connection in ipairs(self.connections) do
connection:disconnect()
end
self.connections = {}
self.groupDetailComponent:Stop()
end
function GroupDetail:Destruct()
self.groupDetailComponent:Destruct()
end
return GroupDetail
@@ -0,0 +1,72 @@
local Modules = script.Parent.Parent.Parent
local Components = Modules.Components
local DialogInfo = require(Modules.DialogInfo)
local BaseScreen = require(Modules.Views.Phone.BaseScreen)
local NewChatGroupComponent = require(Components.NewChatGroup)
local PopRoute = require(Modules.Actions.PopRoute)
local SetRoute = require(Modules.Actions.SetRoute)
local Intent = DialogInfo.Intent
local NewChatGroup = BaseScreen:Template()
NewChatGroup.__index = NewChatGroup
function NewChatGroup.new(appState, route)
local self = {
appState = appState,
route = route,
connections = {};
}
setmetatable(self, NewChatGroup)
self.newChatGroupComponent = NewChatGroupComponent.new(appState)
self.rbx = self.newChatGroupComponent.rbx
local backButtonPressedConnection = self.newChatGroupComponent.BackButtonPressed:connect(function()
self.appState.store:dispatch(PopRoute())
end)
table.insert(self.connections, backButtonPressedConnection)
local conversationSavedConnection = self.newChatGroupComponent.ConversationSaved:connect(function(id)
self.appState.store:dispatch(SetRoute(Intent.Conversation, {conversationId = id}, Intent.ConversationHub))
end)
table.insert(self.connections, conversationSavedConnection)
return self
end
function NewChatGroup:Start()
BaseScreen.Start(self)
do
local connection = self.appState.store.changed:connect(function(current, previous)
self:Update(current, previous)
end)
table.insert(self.connections, connection)
end
end
function NewChatGroup:Stop()
for _, connection in ipairs(self.connections) do
connection:disconnect()
end
self.connections = {}
BaseScreen.Stop(self)
end
function NewChatGroup:Destruct()
self.newChatGroupComponent:Destruct()
self.newChatGroupComponent = nil
BaseScreen.Destruct(self)
end
function NewChatGroup:Update(current, previous)
self.newChatGroupComponent:Update(current, previous)
end
return NewChatGroup