Skip to content

Commit

Permalink
Add members list to info profile.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 16, 2017
1 parent faeb148 commit f2a5862
Show file tree
Hide file tree
Showing 34 changed files with 943 additions and 300 deletions.
25 changes: 15 additions & 10 deletions Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,23 +961,28 @@ namespace {
}

void feedChatAdmins(const MTPDupdateChatAdmins &d) {
ChatData *chat = App::chat(d.vchat_id.v);
auto chat = App::chat(d.vchat_id.v);
if (chat->version <= d.vversion.v) {
bool badVersion = (chat->version + 1 < d.vversion.v);
if (badVersion) {
chat->invalidateParticipants();
Auth().api().requestPeer(chat);
}
auto wasCanEdit = chat->canEdit();
auto badVersion = (chat->version + 1 < d.vversion.v);
chat->version = d.vversion.v;
if (mtpIsTrue(d.venabled)) {
if (!badVersion) {
chat->invalidateParticipants();
}
chat->flags |= MTPDchat::Flag::f_admins_enabled;
} else {
chat->flags &= ~MTPDchat::Flag::f_admins_enabled;
}
Notify::peerUpdatedDelayed(chat, Notify::PeerUpdate::Flag::AdminsChanged);
if (badVersion || mtpIsTrue(d.venabled)) {
chat->invalidateParticipants();
Auth().api().requestPeer(chat);
}
if (wasCanEdit != chat->canEdit()) {
Notify::peerUpdatedDelayed(
chat,
Notify::PeerUpdate::Flag::ChatCanEdit);
}
Notify::peerUpdatedDelayed(
chat,
Notify::PeerUpdate::Flag::AdminsChanged);
}
}

Expand Down
26 changes: 3 additions & 23 deletions Telegram/SourceFiles/history/history.style
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,7 @@ membersInnerDropdown: InnerDropdown(defaultInnerDropdown) {
scrollMargin: margins(0px, 5px, 0px, 5px);
scrollPadding: margins(0px, 3px, 0px, 3px);
}
membersInnerItem: ProfilePeerListItem {
left: 0px;
bottom: 0px;
button: OutlineButton {
outlineWidth: 0px;

textBg: windowBg;
textBgOver: windowBgOver;

textFg: windowSubTextFg;
textFgOver: windowSubTextFgOver;

font: normalFont;
padding: margins(11px, 5px, 11px, 5px);

ripple: defaultRippleAnimation;
}
statusFg: windowSubTextFg;
statusFgOver: windowSubTextFgOver;
statusFgActive: windowActiveTextFg;
}
membersInnerItem: defaultProfileMemberItem;

historyFileOutImage: icon {{ "history_file_image", historyFileOutIconFg }};
historyFileOutImageSelected: icon {{ "history_file_image", historyFileOutIconFgSelected }};
Expand Down Expand Up @@ -456,14 +436,14 @@ historyAdminLogCancelSearch: CrossButton {
height: 54px;

cross: CrossAnimation {
size: 36px;
size: 32px;
skip: 10px;
stroke: 2px;
minScale: 0.3;
}
crossFg: menuIconFg;
crossFgOver: menuIconFgOver;
crossPosition: point(4px, 9px);
crossPosition: point(6px, 11px);

duration: 150;
loadingPeriod: 1000;
Expand Down
108 changes: 99 additions & 9 deletions Telegram/SourceFiles/info/info.style
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ infoIconMediaPhoto: icon {{ "info_media_photo", infoIconFg }};
infoInformationIconPosition: point(25px, 12px);
infoNotificationsIconPosition: point(20px, 5px);
infoSharedMediaIconPosition: point(20px, 24px);
infoMembersIconPosition: point(20px, 15px);

infoLabeledOneLine: FlatLabel(defaultFlatLabel) {
width: 0px; // No need to set minWidth in one-line text.
Expand All @@ -176,6 +177,16 @@ infoLabeled: FlatLabel(infoLabeledOneLine) {
margin: margins(5px, 5px, 5px, 5px);
}

infoBlockHeaderLabel: FlatLabel(infoProfileStatusLabel) {
textFg: windowBoldFg;
style: TextStyle(defaultTextStyle) {
font: semiboldFont;
linkFont: semiboldFont;
linkFontOver: semiboldFont;
}
}
infoBlockHeaderPosition: point(79px, 22px);

infoProfileToggle: Toggle(defaultToggle) {
diameter: 16px;
width: 14px;
Expand Down Expand Up @@ -209,14 +220,93 @@ infoMainButton: InfoProfileButton(infoProfileButton) {
textFgOver: lightButtonFgOver;
}
infoSharedMediaCoverHeight: 62px;
infoSharedMediaLabelPosition: point(79px, 22px);
infoSharedMediaLabel: FlatLabel(infoProfileStatusLabel) {
textFg: windowBoldFg;
style: TextStyle(defaultTextStyle) {
font: semiboldFont;
linkFont: semiboldFont;
linkFontOver: semiboldFont;
}
}
infoSharedMediaButton: infoProfileButton;
infoSharedMediaBottomSkip: 12px;

infoMembersHeader: 56px;
infoMembersItem: ProfilePeerListItem(defaultProfileMemberItem) {
photoPosition: point(18px, 6px);
namePosition: point(79px, 11px);
statusPosition: point(79px, 31px);
}
infoMembersButtonPosition: point(12px, 9px);
infoMembersButtonIconPosition: point(6px, 6px);
infoMembersButton: IconButton(defaultIconButton) {
width: 44px;
height: 44px;
iconPosition: infoMembersButtonIconPosition;
rippleAreaPosition: point(0px, 0px);
rippleAreaSize: 44px;
ripple: RippleAnimation(defaultRippleAnimation) {
color: windowBgOver;
}
}
infoMembersAddMember: IconButton(infoMembersButton) {
icon: icon {{ "info_add_member", menuIconFg }};
iconOver: icon {{ "info_add_member", menuIconFgOver }};
}
infoMembersSearch: IconButton(infoMembersButton) {
icon: icon {{
"top_bar_search",
menuIconFg,
infoMembersButtonIconPosition
}};
iconOver: icon {{
"top_bar_search",
menuIconFgOver,
infoMembersButtonIconPosition
}};
iconPosition: point(0px, 0px);
}
infoMembersSearchActive: icon {
{ size(44px, 44px), windowBg },
{
"top_bar_search",
menuIconFgOver,
infoMembersButtonIconPosition
}
};
infoMembersSearchActiveLayer: icon {
{ size(44px, 44px), boxBg },
{
"top_bar_search",
menuIconFgOver,
infoMembersButtonIconPosition
}
};
infoMembersSearchField: FlatInput(defaultFlatInput) {
textColor: windowFg;
bgColor: topBarBg;
bgActive: topBarBg;

font: font(fsize);

borderWidth: 0px;
borderColor: topBarBg;
borderActive: topBarBg;

width: 100px;
height: 32px;
textMrg: margins(0px, 0px, 0px, 0px);
}
infoMembersCancelSearch: CrossButton {
width: 44px;
height: 44px;

cross: CrossAnimation {
size: 44px;
skip: 16px;
stroke: 2px;
minScale: 0.3;
}
crossFg: menuIconFg;
crossFgOver: menuIconFgOver;
crossPosition: point(0px, 0px);

duration: 150;
loadingPeriod: 1000;
ripple: RippleAnimation(defaultRippleAnimation) {
color: windowBgOver;
}
}
infoMembersSearchTop: 15px;
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/info/info_layer_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "info/info_memento.h"
#include "info/info_top_bar.h"
#include "ui/rp_widget.h"
#include "ui/focus_persister.h"
#include "ui/widgets/buttons.h"
#include "window/section_widget.h"
#include "window/window_controller.h"
Expand Down Expand Up @@ -106,6 +107,7 @@ void LayerWrap::parentResized() {
auto parentSize = parentWidget()->size();
auto parentWidth = parentSize.width();
if (parentWidth < MinimalSupportedWidth()) {
Ui::FocusPersister persister(this);
auto localCopy = _controller;
auto memento = MoveMemento(std::move(_content), Wrap::Narrow);
localCopy->hideSpecialLayer(anim::type::instant);
Expand All @@ -124,6 +126,7 @@ void LayerWrap::parentResized() {
}

bool LayerWrap::takeToThirdSection() {
Ui::FocusPersister persister(this);
auto localCopy = _controller;
auto memento = MoveMemento(std::move(_content), Wrap::Side);
localCopy->hideSpecialLayer(anim::type::instant);
Expand Down
18 changes: 11 additions & 7 deletions Telegram/SourceFiles/info/info_memento.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "info/info_memento.h"

#include <rpl/never.h>
#include <rpl/combine.h>
#include "window/window_controller.h"
#include "ui/widgets/scroll_area.h"
#include "lang/lang_keys.h"
Expand Down Expand Up @@ -51,7 +52,7 @@ ContentWidget::ContentWidget(
void ContentWidget::setWrap(Wrap wrap) {
if (_wrap != wrap) {
_wrap = wrap;
wrapUpdatedHook();
_wrapChanges.fire_copy(_wrap);
update();
}
}
Expand All @@ -62,7 +63,6 @@ void ContentWidget::resizeEvent(QResizeEvent *e) {
QMargins(0, _scrollTopSkip, 0, 0));
if (_scroll->geometry() != scrollGeometry) {
_scroll->setGeometry(scrollGeometry);
_inner->setMinimumHeight(_scroll->height());
_inner->resizeToWidth(_scroll->width());
}

Expand Down Expand Up @@ -100,14 +100,18 @@ void ContentWidget::setGeometryWithTopMoved(
Ui::RpWidget *ContentWidget::doSetInnerWidget(
object_ptr<RpWidget> inner,
int scrollTopSkip) {
using namespace rpl::mappers;

_inner = _scroll->setOwnedWidget(std::move(inner));
_inner->move(0, 0);

scrollTopValue()
| rpl::start([this, inner = _inner](int value) {
inner->setVisibleTopBottom(
value,
value + _scroll->height()); // TODO rpl::combine
rpl::combine(
_scroll->scrollTopValue(),
_scroll->heightValue(),
_inner->desiredHeightValue(),
tuple($1, $1 + $2, $3))
| rpl::start([inner = _inner](int top, int bottom, int desired) {
inner->setVisibleTopBottom(top, bottom);
}, _inner->lifetime());
return _inner;
}
Expand Down
8 changes: 3 additions & 5 deletions Telegram/SourceFiles/info/info_memento.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class ContentWidget : public Ui::RpWidget {
not_null<Window::Controller*> controller() const {
return _controller;
}
Wrap wrap() const {
return _wrap;
rpl::producer<Wrap> wrapValue() const {
return _wrapChanges.events_starting_with_copy(_wrap);
}

void resizeEvent(QResizeEvent *e) override;
Expand All @@ -132,9 +132,6 @@ class ContentWidget : public Ui::RpWidget {
int scrollTopSave() const;
void scrollTopRestore(int scrollTop);

virtual void wrapUpdatedHook() {
}

private:
RpWidget *doSetInnerWidget(
object_ptr<RpWidget> inner,
Expand All @@ -143,6 +140,7 @@ class ContentWidget : public Ui::RpWidget {
const not_null<Window::Controller*> _controller;
const not_null<PeerData*> _peer;
Wrap _wrap = Wrap::Layer;
rpl::event_stream<Wrap> _wrapChanges;

int _scrollTopSkip = 0;
object_ptr<Ui::ScrollArea> _scroll;
Expand Down
6 changes: 3 additions & 3 deletions Telegram/SourceFiles/info/profile/info_profile_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ Button::Button(
}

Button *Button::toggleOn(rpl::producer<bool> &&toggled) {
_toggleOnLifetime.destroy();
Expects(_toggle == nullptr);
_toggle = std::make_unique<Ui::ToggleView>(
isOver() ? _st.toggleOver : _st.toggle,
false,
[this] { rtlupdate(toggleRect()); });
clicks()
| rpl::start([this](auto) {
_toggle->setCheckedAnimated(!_toggle->checked());
}, _toggleOnLifetime);
}, lifetime());
std::move(toggled)
| rpl::start([this](bool toggled) {
_toggle->setCheckedAnimated(toggled);
}, _toggleOnLifetime);
}, lifetime());
_toggle->finishAnimation();
return this;
}
Expand Down
1 change: 0 additions & 1 deletion Telegram/SourceFiles/info/profile/info_profile_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class Button : public Ui::RippleButton {
int _originalWidth = 0;
int _textWidth = 0;
std::unique_ptr<Ui::ToggleView> _toggle;
rpl::lifetime _toggleOnLifetime;

};

Expand Down
Loading

0 comments on commit f2a5862

Please sign in to comment.