Skip to content

Commit

Permalink
Clickable urls(#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglascdev committed Dec 13, 2023
1 parent dd81651 commit 24896d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Changes:
* Render global 7tv emotes
* Show tooltip with emote's name when hovering over it
* Clickable urls(#47)

12 changes: 10 additions & 2 deletions hasherino/components/chat_message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABC

import flet as ft
import validators

from hasherino.hasherino_dataclasses import Emote, Message
from hasherino.pubsub import PubSub
Expand All @@ -11,9 +12,16 @@ async def on_font_size_changed(self, new_font_size: int):
...


class ChatText(ft.Text, FontSizeSubscriber):
class ChatText(ft.Container, FontSizeSubscriber):
def __init__(self, text: str, color: str, size: int, weight=""):
super().__init__(text, size=size, weight=weight, color=color, selectable=True)
try:
is_url = validators.url(text)
except validators.ValidationError:
is_url = False

color = ft.colors.BLUE if is_url else color
content = ft.Text(text, size=size, weight=weight, color=color, selectable=True)
super().__init__(content=content, url=text)

async def on_font_size_changed(self, new_font_size: int):
self.size = new_font_size
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies = [
"keyring == 24.2.0",
"flet == 0.15.0",
"certifi == 2023.7.22",
"validators == 0.22.0",
]

[tool.isort]
Expand Down

0 comments on commit 24896d8

Please sign in to comment.