local W=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local q=game:GetService("\080\108\097\121\101\114\115")local e=W.AvatarEditor local t=require(e.Shared.Util.Maid)local V=require(e.Shared.Util.Promise)local d=require(e.Client.GuiLib.LazyLoader)local E=require(e.Client.Theme)local L=(require(e.Gui.DropdownTemplateToLua))()local v=q.LocalPlayer local F={}F.__index=F function F.new(W)local q=setmetatable({},F)q.Frame=W q.ScrollingFrame=q.Frame.ScrollingFrame q.Maid=t.new()q.Maid:GiveTask(E:Bind(q.ScrollingFrame,"\083\099\114\111\108\108\066\097\114\073\109\097\103\101\067\111\108\111\114\051","\083\099\114\111\108\108\098\097\114"))q.Maid:GiveTask(E:Bind(q.ScrollingFrame.Theme.DropdownButton,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051","\084\101\114\116\105\097\114\121"))q.Maid:GiveTask(E:Bind(q.ScrollingFrame.Theme.DropdownButton.ListFrame,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051","\084\101\114\116\105\097\114\121"))q.Maid:GiveTask(E:Bind(q.ScrollingFrame.Theme.DropdownButton.Arrow,"\073\109\097\103\101\067\111\108\111\114\051","\068\101\115\101\108\101\099\116\101\100"))q.Maid:GiveTask(E:Bind(q.ScrollingFrame.Theme.DropdownButton.Option,"\084\101\120\116\067\111\108\111\114\051","\084\101\120\116"))q.Maid:GiveTask(E:Bind(q.ScrollingFrame.Theme.TextLabel,"\084\101\120\116\067\111\108\111\114\051","\084\101\120\116"))local e=q.ScrollingFrame.Theme.DropdownButton for W,t in ipairs(E:GetAll())do local V=L:Clone()V.LayoutOrder=W V.Text=t V.Name=t q.Maid:GiveTask(E:Bind(V,"\066\097\099\107\103\114\111\117\110\100\067\111\108\111\114\051","\084\101\114\116\105\097\114\121"))q.Maid:GiveTask(E:Bind(V,"\084\101\120\116\067\111\108\111\114\051","\084\101\120\116"))q.Maid:GiveTask(V)V.Parent=e.ListFrame.ScrollFrame end q.Maid:GiveTask(E:Bind(e.ListFrame.ScrollFrame,"\083\099\114\111\108\108\066\097\114\073\109\097\103\101\067\111\108\111\114\051","\083\099\114\111\108\108\098\097\114"))e.ListFrame.ScrollFrame.CanvasSize=UDim2.new(0,0,0,e.ListFrame.ScrollFrame.UIListLayout.AbsoluteContentSize.Y)local U=d.Classes.Dropdown.new(e,e.ListFrame)q.Maid:GiveTask(U)q.Maid:GiveTask(U.Changed:Connect(function(W)local q=W.Name E:Set(q)end));((V.new(function(W,q)local e=v:WaitForChild("\065\069\095\083\101\116\116\105\110\103\115")W(e)end)):andThen(function(W)q.Folder=W U:Set(e.ListFrame.ScrollFrame[q.Folder:GetAttribute("\084\104\101\109\101")])E:Set((U:Get()).Name)end)):catch(warn)return q end function F.Destroy(W)W.Maid:DoCleaning()W.Maid=nil setmetatable(W,nil)end return F
-- Class
-- 0_1195
-- January 10, 2021

--[[



]]

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local AvatarEditor = ReplicatedStorage.AvatarEditor
local Maid = require(AvatarEditor.Shared.Util.Maid)
local Promise = require(AvatarEditor.Shared.Util.Promise)
local GuiLib = require(AvatarEditor.Client.GuiLib.LazyLoader)
local Theme = require(AvatarEditor.Client.Theme)

local buttonTemplate = require(AvatarEditor.Gui.DropdownTemplateToLua)()

local player = Players.LocalPlayer

local Class = {}
Class.__index = Class


function Class.new(frame)
	local self = setmetatable({}, Class)
	
	self.Frame = frame
	self.ScrollingFrame = self.Frame.ScrollingFrame
	self.Maid = Maid.new()

	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame, "ScrollBarImageColor3", "Scrollbar"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton, "BackgroundColor3", "Tertiary"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton.ListFrame, "BackgroundColor3", "Tertiary"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton.Arrow, "ImageColor3", "Deselected"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.DropdownButton.Option, "TextColor3", "Text"))
	self.Maid:GiveTask(Theme:Bind(self.ScrollingFrame.Theme.TextLabel, "TextColor3", "Text"))
	
	local dropdownButton = self.ScrollingFrame.Theme.DropdownButton
	for i, v in ipairs(Theme:GetAll()) do
		local button = buttonTemplate:Clone()
		button.LayoutOrder = i
		button.Text = v
		button.Name = v
		self.Maid:GiveTask(Theme:Bind(button, "BackgroundColor3", "Tertiary"))
		self.Maid:GiveTask(Theme:Bind(button, "TextColor3", "Text"))
		self.Maid:GiveTask(button)
		button.Parent = dropdownButton.ListFrame.ScrollFrame
	end
	self.Maid:GiveTask(Theme:Bind(dropdownButton.ListFrame.ScrollFrame, "ScrollBarImageColor3", "Scrollbar"))
	
	-- for some reason AutomaticCanvasSize doesnt want to work here...
	dropdownButton.ListFrame.ScrollFrame.CanvasSize = UDim2.new(0, 0, 0, dropdownButton.ListFrame.ScrollFrame.UIListLayout.AbsoluteContentSize.Y)
	
	local themeDropdown = GuiLib.Classes.Dropdown.new(dropdownButton, dropdownButton.ListFrame)
	self.Maid:GiveTask(themeDropdown)
	
	self.Maid:GiveTask(themeDropdown.Changed:Connect(function(button)
		local theme = button.Name
		Theme:Set(theme)
	end))
	
	Promise.new(function(resolve, reject)
		local folder = player:WaitForChild("AE_Settings")
		resolve(folder)
	end)
	:andThen(function(folder)
		self.Folder = folder
		
		themeDropdown:Set(dropdownButton.ListFrame.ScrollFrame[self.Folder:GetAttribute("Theme")])
		Theme:Set(themeDropdown:Get().Name)
	end)
	:catch(warn)
	
	return self
end


function Class:Destroy()
	self.Maid:DoCleaning()
	self.Maid = nil
	setmetatable(self, nil)
end


return Class