feat: update to latest status go and add color to the community

This commit is contained in:
Jonathan Rainville 2021-03-01 14:43:50 -05:00 committed by Iuri Matias
parent e28e98a394
commit e52f6daec9
4 changed files with 45 additions and 41 deletions

View File

@ -183,11 +183,11 @@ QtObject:
return true
return false
proc createCommunity*(self: CommunitiesView, name: string, description: string, access: int, ensOnly: bool, imagePath: string, aX: int, aY: int, bX: int, bY: int): string {.slot.} =
proc createCommunity*(self: CommunitiesView, name: string, description: string, access: int, ensOnly: bool, color: string, imagePath: string, aX: int, aY: int, bX: int, bY: int): string {.slot.} =
result = ""
try:
var image = image_utils.formatImagePath(imagePath)
let community = self.status.chat.createCommunity(name, description, access, ensOnly, image, aX, aY, bX, bY)
let community = self.status.chat.createCommunity(name, description, access, ensOnly, color, image, aX, aY, bX, bY)
if (community.id == ""):
return "Community was not created. Please try again later"

View File

@ -416,8 +416,8 @@ proc getAllComunities*(self: ChatModel): seq[Community] =
proc getJoinedComunities*(self: ChatModel): seq[Community] =
result = status_chat.getJoinedComunities()
proc createCommunity*(self: ChatModel, name: string, description: string, access: int, ensOnly: bool, imageUrl: string, aX: int, aY: int, bX: int, bY: int): Community =
result = status_chat.createCommunity(name, description, access, ensOnly, imageUrl, aX, aY, bX, bY)
proc createCommunity*(self: ChatModel, name: string, description: string, access: int, ensOnly: bool, color: string, imageUrl: string, aX: int, aY: int, bX: int, bY: int): Community =
result = status_chat.createCommunity(name, description, access, ensOnly, color, imageUrl, aX, aY, bX, bY)
proc createCommunityChannel*(self: ChatModel, communityId: string, name: string, description: string): Chat =
result = status_chat.createCommunityChannel(communityId, name, description)

View File

@ -257,13 +257,14 @@ proc getJoinedComunities*(): seq[Community] =
communities.add(community)
return communities
proc createCommunity*(name: string, description: string, access: int, ensOnly: bool, imageUrl: string, aX: int, aY: int, bX: int, bY: int): Community =
proc createCommunity*(name: string, description: string, access: int, ensOnly: bool, color: string, imageUrl: string, aX: int, aY: int, bX: int, bY: int): Community =
let rpcResult = callPrivateRPC("createCommunity".prefix, %*[{
# TODO this will need to be renamed membership (small m)
"Membership": access,
"name": name,
"description": description,
"ensOnly": ensOnly,
"color": color,
"image": imageUrl,
"imageAx": aX,
"imageAy": aY,

View File

@ -32,8 +32,6 @@ ModalPopup {
nameValidationError = "";
colorValidationError = "";
selectedImageValidationError = "";
// TODO: add color and profile pic
// TODO: can privacy be changed?
nameInput.forceActiveFocus(Qt.MouseFocusReason)
}
@ -58,11 +56,11 @@ ModalPopup {
selectedImageValidationError = qsTrId("you-need-to-select-an-image")
}
// if (colorPicker.text === "") {
// colorValidationError = qsTr("You need to enter a color")
// } else if (!Utils.isHexColor(colorPicker.text)) {
// colorValidationError = qsTr("This field needs to be an hexadecimal color (eg: #4360DF)")
// }
if (colorPicker.text === "") {
colorValidationError = qsTr("You need to enter a color")
} else if (!Utils.isHexColor(colorPicker.text)) {
colorValidationError = qsTr("This field needs to be an hexadecimal color (eg: #4360DF)")
}
return !nameValidationError && !descriptionTextArea.validationError && !colorValidationError
}
@ -248,40 +246,44 @@ ModalPopup {
}
}
// TODO re-add color picker when status-go supports it
// Input {
// id: colorPicker
// label: qsTr("Community color")
// placeholderText: qsTr("Pick a color")
// anchors.top: addImageButton.bottom
// anchors.topMargin: Style.current.smallPadding
// validationError: popup.colorValidationError
Input {
property string defaultColor: "#4360DF"
// StatusIconButton {
// icon.name: "caret"
// iconRotation: -90
// iconColor: Style.current.textColor
// icon.width: 13
// icon.height: 7
// anchors.right: parent.right
// anchors.rightMargin: Style.current.smallPadding
// anchors.top: parent.top
// anchors.topMargin: colorPicker.textField.height / 2 - height / 2 + Style.current.bigPadding
// onClicked: colorDialog.open()
// }
id: colorPicker
label: qsTr("Community color")
placeholderText: qsTr("Pick a color")
anchors.top: addImageButton.bottom
anchors.topMargin: Style.current.smallPadding
validationError: popup.colorValidationError
textField.text: defaultColor
textField.onReleased: colorDialog.open()
// ColorDialog {
// id: colorDialog
// title: qsTr("Please choose a color")
// onAccepted: {
// colorPicker.text = colorDialog.color
// }
// }
// }
StatusIconButton {
icon.name: "caret"
iconRotation: -90
iconColor: Style.current.textColor
icon.width: 13
icon.height: 7
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding
anchors.top: parent.top
anchors.topMargin: colorPicker.textField.height / 2 - height / 2 + Style.current.bigPadding
onClicked: colorDialog.open()
}
ColorDialog {
id: colorDialog
title: qsTr("Please choose a color")
color: colorPicker.defaultColor
onAccepted: {
colorPicker.text = colorDialog.color
}
}
}
Separator {
id: separator1
anchors.top: addImageButton.bottom
anchors.top: colorPicker.bottom
anchors.topMargin: isEdit ? 0 : Style.current.bigPadding
visible: !isEdit
}
@ -361,6 +363,7 @@ ModalPopup {
Utils.filterXSS(descriptionTextArea.text),
membershipRequirementSettingPopup.checkedMembership,
ensOnlySwitch.switchChecked,
colorPicker.text,
popup.selectedImage,
imageDimensions.aX,
imageDimensions.aY,