Reduce GTK dependency to 3.16, fix dark theme
This commit is contained in:
parent
bb811f8b29
commit
2804799f61
|
@ -47,9 +47,10 @@ public class PresenceManager : StreamInteractionModule, Object {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ArrayList<Jid> ret = new ArrayList<Jid>(Jid.equals_func);
|
ArrayList<Jid> ret = new ArrayList<Jid>(Jid.equals_func);
|
||||||
foreach (string resource in resources) {
|
resources.foreach((resource) => {
|
||||||
ret.add(new Jid(resource));
|
ret.add(new Jid(resource));
|
||||||
}
|
return true;
|
||||||
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -44,7 +44,6 @@ set(RESOURCE_LIST
|
||||||
menu_encryption.ui
|
menu_encryption.ui
|
||||||
occupant_list.ui
|
occupant_list.ui
|
||||||
occupant_list_item.ui
|
occupant_list_item.ui
|
||||||
style.css
|
|
||||||
settings_dialog.ui
|
settings_dialog.ui
|
||||||
unified_window.ui
|
unified_window.ui
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiAddConversationChatAddContactDialog">
|
<template class="DinoUiAddConversationChatAddContactDialog">
|
||||||
<property name="default_width">300</property>
|
<property name="default_width">300</property>
|
||||||
<property name="modal">True</property>
|
<property name="modal">True</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiAddConversationConferenceAddGroupchatDialog">
|
<template class="DinoUiAddConversationConferenceAddGroupchatDialog">
|
||||||
<property name="default_width">400</property>
|
<property name="default_width">400</property>
|
||||||
<property name="modal">True</property>
|
<property name="modal">True</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiAddConversationConferenceConferenceDetailsFragment">
|
<template class="DinoUiAddConversationConferenceConferenceDetailsFragment">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiAddConversationListRow" parent="GtkListBoxRow">
|
<template class="DinoUiAddConversationListRow" parent="GtkListBoxRow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiAddConversationSelectJidFragment">
|
<template class="DinoUiAddConversationSelectJidFragment">
|
||||||
<property name="height_request">500</property>
|
<property name="height_request">500</property>
|
||||||
<property name="width_request">460</property>
|
<property name="width_request">460</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiConversationListTitlebar" parent="GtkHeaderBar">
|
<template class="DinoUiConversationListTitlebar" parent="GtkHeaderBar">
|
||||||
<property name="hexpand">False</property>
|
<property name="hexpand">False</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<object class="GtkBox" id="main_box">
|
<object class="GtkBox" id="main_box">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiConversationSelectorConversationRow">
|
<template class="DinoUiConversationSelectorConversationRow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiConversationSelectorView">
|
<template class="DinoUiConversationSelectorView">
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="width_request">40</property>
|
<property name="width_request">40</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiConversationSummaryMergedMessageItem">
|
<template class="DinoUiConversationSummaryMergedMessageItem">
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
<property name="column-spacing">7</property>
|
<property name="column-spacing">7</property>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiConversationSummaryView">
|
<template class="DinoUiConversationSummaryView">
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="homogeneous">False</property>
|
||||||
|
<property name="spacing">0</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow" id="scrolled">
|
<object class="GtkScrolledWindow" id="scrolled">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiConversationTitlebar" parent="GtkHeaderBar">
|
<template class="DinoUiConversationTitlebar" parent="GtkHeaderBar">
|
||||||
<property name="title"></property>
|
<property name="title"></property>
|
||||||
<property name="hexpand">True</property>
|
<property name="hexpand">True</property>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiManageAccountsAccountRow">
|
<template class="DinoUiManageAccountsAccountRow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiManageAccountsAddAccountDialog">
|
<template class="DinoUiManageAccountsAddAccountDialog">
|
||||||
<property name="default_width">300</property>
|
<property name="default_width">300</property>
|
||||||
<property name="modal">True</property>
|
<property name="modal">True</property>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.20"/>
|
<requires lib="gtk+" version="3.16"/>
|
||||||
<object class="GtkPopoverMenu" id="menu_encryption">
|
<object class="GtkPopoverMenu" id="menu_encryption">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiOccupantList">
|
<template class="DinoUiOccupantList">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiOccupantListRow" parent="GtkListBoxRow">
|
<template class="DinoUiOccupantListRow" parent="GtkListBoxRow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiSettingsDialog">
|
<template class="DinoUiSettingsDialog">
|
||||||
<property name="modal">True</property>
|
<property name="modal">True</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
scrolledwindow {
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.0"/>
|
|
||||||
<template class="DinoUiWindow">
|
<template class="DinoUiWindow">
|
||||||
<property name="default-width">1200</property>
|
<property name="default-width">1200</property>
|
||||||
<property name="default-height">700</property>
|
<property name="default-height">700</property>
|
||||||
|
|
|
@ -16,8 +16,6 @@ public class Dino.Ui.Application : Dino.Application {
|
||||||
notifications = new Notifications(stream_interaction);
|
notifications = new Notifications(stream_interaction);
|
||||||
notifications.start();
|
notifications.start();
|
||||||
Environment.set_application_name("Dino");
|
Environment.set_application_name("Dino");
|
||||||
|
|
||||||
load_css();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void activate() {
|
public override void activate() {
|
||||||
|
@ -83,16 +81,5 @@ public class Dino.Ui.Application : Dino.Application {
|
||||||
private void remove_connection(Account account) {
|
private void remove_connection(Account account) {
|
||||||
stream_interaction.disconnect(account);
|
stream_interaction.disconnect(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load_css() {
|
|
||||||
var css_provider = new Gtk.CssProvider ();
|
|
||||||
try {
|
|
||||||
var file = File.new_for_uri("resource:///org/dino-im/style.css");
|
|
||||||
css_provider.load_from_file (file);
|
|
||||||
} catch (GLib.Error e) {
|
|
||||||
warning ("loading css: %s", e.message);
|
|
||||||
}
|
|
||||||
Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,21 +22,50 @@ public class MergedMessageItem : Grid {
|
||||||
[GtkChild] private Image received_image;
|
[GtkChild] private Image received_image;
|
||||||
[GtkChild] private TextView message_text_view;
|
[GtkChild] private TextView message_text_view;
|
||||||
|
|
||||||
|
private StreamInteractor stream_interactor;
|
||||||
|
private TextTag link_tag;
|
||||||
|
|
||||||
public MergedMessageItem(StreamInteractor stream_interactor, Conversation conversation, Message message) {
|
public MergedMessageItem(StreamInteractor stream_interactor, Conversation conversation, Message message) {
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
this.from = message.from;
|
this.from = message.from;
|
||||||
this.initial_time = message.time;
|
this.initial_time = message.time;
|
||||||
|
this.stream_interactor = stream_interactor;
|
||||||
setup_tags();
|
setup_tags();
|
||||||
add_message(message);
|
add_message(message);
|
||||||
|
|
||||||
time_label.label = get_relative_time(initial_time.to_local());
|
time_label.label = get_relative_time(initial_time.to_local());
|
||||||
string display_name = Util.get_message_display_name(stream_interactor, message, conversation.account);
|
|
||||||
name_label.set_markup(@"<span foreground=\"#$(Util.get_name_hex_color(display_name))\">$display_name</span>");
|
|
||||||
Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(30, 30, image.scale_factor)).draw_message(stream_interactor, message));
|
Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(30, 30, image.scale_factor)).draw_message(stream_interactor, message));
|
||||||
if (message.encryption != Encryption.NONE) {
|
if (message.encryption != Encryption.NONE) {
|
||||||
encryption_image.visible = true;
|
encryption_image.visible = true;
|
||||||
encryption_image.set_from_icon_name("changes-prevent-symbolic", IconSize.SMALL_TOOLBAR);
|
encryption_image.set_from_icon_name("changes-prevent-symbolic", IconSize.SMALL_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
name_label.label = Util.get_message_display_name(stream_interactor, message, conversation.account);
|
||||||
|
|
||||||
|
update_display_style();
|
||||||
|
message_text_view.style_updated.connect(style_changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void style_changed() {
|
||||||
|
lock(message_text_view) {
|
||||||
|
message_text_view.style_updated.disconnect(style_changed);
|
||||||
|
update_display_style();
|
||||||
|
message_text_view.style_updated.connect(style_changed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update_display_style() {
|
||||||
|
TextView tmp = new TextView();
|
||||||
|
RGBA bg = tmp.get_style_context().get_background_color(StateFlags.NORMAL);
|
||||||
|
bool dark_theme = (bg.red < 0.5 && bg.green < 0.5 && bg.blue < 0.5);
|
||||||
|
|
||||||
|
string display_name = Util.get_message_display_name(stream_interactor, messages[0], conversation.account);
|
||||||
|
name_label.set_markup(@"<span foreground=\"#$(Util.get_name_hex_color(display_name, dark_theme))\">$display_name</span>");
|
||||||
|
|
||||||
|
LinkButton lnk = new LinkButton("http://example.com");
|
||||||
|
RGBA link_color = lnk.get_style_context().get_color(StateFlags.LINK);
|
||||||
|
link_tag.foreground_rgba = link_color;
|
||||||
|
|
||||||
|
message_text_view.override_background_color(0, {0,0,0,0});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
@ -104,7 +133,7 @@ public class MergedMessageItem : Grid {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup_tags() {
|
private void setup_tags() {
|
||||||
message_text_view.buffer.create_tag("url", underline: Pango.Underline.SINGLE, foreground: "blue");
|
link_tag = message_text_view.buffer.create_tag("url", underline: Pango.Underline.SINGLE, foreground: "blue");
|
||||||
message_text_view.button_release_event.connect(open_url);
|
message_text_view.button_release_event.connect(open_url);
|
||||||
message_text_view.motion_notify_event.connect(change_cursor_over_url);
|
message_text_view.motion_notify_event.connect(change_cursor_over_url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ public class View : Box {
|
||||||
bool reloading = false;
|
bool reloading = false;
|
||||||
|
|
||||||
public View(StreamInteractor stream_interactor) {
|
public View(StreamInteractor stream_interactor) {
|
||||||
Object(homogeneous : false, spacing : 0);
|
|
||||||
this.stream_interactor = stream_interactor;
|
this.stream_interactor = stream_interactor;
|
||||||
scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify);
|
scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify);
|
||||||
scrolled.vadjustment.notify["value"].connect(on_value_notify);
|
scrolled.vadjustment.notify["value"].connect(on_value_notify);
|
||||||
|
@ -50,6 +49,23 @@ public class View : Box {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
update_background_color();
|
||||||
|
this.style_updated.connect(style_changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update_background_color() {
|
||||||
|
TextView tmp = new TextView();
|
||||||
|
this.override_background_color(0, tmp.get_style_context().get_background_color(0));
|
||||||
|
main.override_background_color(0, tmp.get_style_context().get_background_color(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void style_changed() {
|
||||||
|
lock (main) {
|
||||||
|
this.style_updated.disconnect(style_changed);
|
||||||
|
update_background_color();
|
||||||
|
this.style_updated.connect(style_changed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize_for_conversation(Conversation? conversation) {
|
public void initialize_for_conversation(Conversation? conversation) {
|
||||||
|
@ -129,7 +145,7 @@ public class View : Box {
|
||||||
if (was_upper == null || scrolled.vadjustment.value > was_upper - was_page_size - 1 ||
|
if (was_upper == null || scrolled.vadjustment.value > was_upper - was_page_size - 1 ||
|
||||||
scrolled.vadjustment.value > was_upper - was_page_size - 1) { // scrolled down or content smaller than page size
|
scrolled.vadjustment.value > was_upper - was_page_size - 1) { // scrolled down or content smaller than page size
|
||||||
scrolled.vadjustment.value = scrolled.vadjustment.upper - scrolled.vadjustment.page_size; // scroll down
|
scrolled.vadjustment.value = scrolled.vadjustment.upper - scrolled.vadjustment.page_size; // scroll down
|
||||||
} else if (scrolled.vadjustment.value < scrolled.vadjustment.upper - scrolled.vadjustment.page_size - 1){
|
} else if (scrolled.vadjustment.value < scrolled.vadjustment.upper - scrolled.vadjustment.page_size - 1) {
|
||||||
scrolled.vadjustment.value = scrolled.vadjustment.upper - was_upper + scrolled.vadjustment.value; // stay at same content
|
scrolled.vadjustment.value = scrolled.vadjustment.upper - was_upper + scrolled.vadjustment.value; // stay at same content
|
||||||
}
|
}
|
||||||
was_upper = scrolled.vadjustment.upper;
|
was_upper = scrolled.vadjustment.upper;
|
||||||
|
|
|
@ -9,17 +9,21 @@ public class Util : Object {
|
||||||
|
|
||||||
private const string[] tango_colors_light = {"FCE94F", "FCAF3E", "E9B96E", "8AE234", "729FCF", "AD7FA8", "EF2929"};
|
private const string[] tango_colors_light = {"FCE94F", "FCAF3E", "E9B96E", "8AE234", "729FCF", "AD7FA8", "EF2929"};
|
||||||
private const string[] tango_colors_medium = {"EDD400", "F57900", "C17D11", "73D216", "3465A4", "75507B", "CC0000"};
|
private const string[] tango_colors_medium = {"EDD400", "F57900", "C17D11", "73D216", "3465A4", "75507B", "CC0000"};
|
||||||
private const string[] material_colors_500 = {"F44336", "E91E63", "9C27B0", "673AB7", "3f51B5", "2196F3", "03A9f4", "00BCD4", "009688", "4CAF50", "8BC34a", "CDDC39", "FFEB3B", "FFC107", "FF9800", "FF5722", "795548"};
|
private const string[] material_colors_500 = {"F44336", "E91E63", "9C27B0", "673AB7", "3f51B5", "2196F3", "03A9f4", "00BCD4", "009688", "4CAF50", "8BC34a", "CDDC39", "FFC107", "FF9800", "FF5722", "795548"};
|
||||||
private const string[] material_colors_300 = {"E57373", "F06292", "BA68C8", "9575CD", "7986CB", "64B5F6", "4FC3F7", "4DD0E1", "4DB6AC", "81C784", "AED581", "DCE775", "FFF176", "FFD54F", "FFB74D", "FF8A65", "A1887F"};
|
private const string[] material_colors_300 = {"E57373", "F06292", "BA68C8", "9575CD", "7986CB", "64B5F6", "4FC3F7", "4DD0E1", "4DB6AC", "81C784", "AED581", "DCE775", "FFD54F", "FFB74D", "FF8A65", "A1887F"};
|
||||||
private const string[] material_colors_200 = {"EF9A9A", "F48FB1", "CE93D8", "B39DDB", "9FA8DA", "90CAF9", "81D4FA", "80DEEA", "80CBC4", "A5D6A7", "C5E1A5", "E6EE9C", "FFF59D", "FFE082", "FFCC80", "FFAB91", "BCAAA4"};
|
private const string[] material_colors_200 = {"EF9A9A", "F48FB1", "CE93D8", "B39DDB", "9FA8DA", "90CAF9", "81D4FA", "80DEEA", "80CBC4", "A5D6A7", "C5E1A5", "E6EE9C", "FFE082", "FFCC80", "FFAB91", "BCAAA4"};
|
||||||
|
|
||||||
public static string get_avatar_hex_color(string name) {
|
public static string get_avatar_hex_color(string name) {
|
||||||
return material_colors_300[name.hash() % material_colors_300.length];
|
return material_colors_300[name.hash() % material_colors_300.length];
|
||||||
// return tango_colors_light[name.hash() % tango_colors_light.length];
|
// return tango_colors_light[name.hash() % tango_colors_light.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string get_name_hex_color(string name) {
|
public static string get_name_hex_color(string name, bool dark_theme = false) {
|
||||||
|
if (dark_theme) {
|
||||||
|
return material_colors_300[name.hash() % material_colors_300.length];
|
||||||
|
} else {
|
||||||
return material_colors_500[name.hash() % material_colors_500.length];
|
return material_colors_500[name.hash() % material_colors_500.length];
|
||||||
|
}
|
||||||
// return tango_colors_medium[name.hash() % tango_colors_medium.length];
|
// return tango_colors_medium[name.hash() % tango_colors_medium.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue