Skip to content

Commit d9feea7

Browse files
committed
chat updates
1 parent a1b6ec4 commit d9feea7

File tree

8 files changed

+86
-24
lines changed

8 files changed

+86
-24
lines changed

main/scn/chat_node/chat_node.gd

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var send_message_scene : PackedScene = preload("res://main/scn/message_node/send
1111

1212
var chat_id : String
1313

14+
var user : UsersManager.User
1415
var user_id : String
1516
var user_name : String
1617
var user_avatar : ImageTexture
@@ -49,7 +50,10 @@ func _ready():
4950
func create_chat(document : FirestoreDocument):
5051
set_user_id(document.doc_name)
5152
set_user_name(document.doc_fields.username)
52-
set_user_avatar(UsersManager.get_user_by_id(document.doc_name).picture)
53+
user = UsersManager.get_user_by_id(document.doc_name)
54+
if not user.is_connected("update_picture", self, "set_user_avatar"):
55+
user.connect("update_picture", self, "set_user_avatar")
56+
set_user_avatar(user.picture)
5357
# If friend doesn't have a chat with me and
5458
if not document.doc_fields.chats.has(UserData.user_id):
5559
# If I don't have a chat with friend
@@ -91,9 +95,13 @@ func add_message(key : String, message : Dictionary) -> Label:
9195
lbl = send_message_scene.instance()
9296
else:
9397
lbl = received_message_scene.instance()
94-
lbl.set_text(message.content)
9598
history_messages.add_child(lbl)
99+
lbl.set_text(message.content)
96100
lbl.set_name(key)
101+
yield(get_tree(), "idle_frame")
102+
lbl.show()
103+
yield(get_tree(), "idle_frame")
104+
$ChatContainer/History.scroll_vertical = $ChatContainer/History.get_v_scrollbar().max_value
97105
return lbl
98106

99107
func _on_db_data(resource : FirebaseResource):
@@ -108,8 +116,6 @@ func _on_db_data(resource : FirebaseResource):
108116
else:
109117
RequestsManager.read_message(resource, db_reference)
110118
add_message(resource.key, resource.data.message)
111-
yield(get_tree(), "idle_frame")
112-
$ChatContainer/History.scroll_vertical = $ChatContainer/History.get_v_scrollbar().max_value
113119

114120

115121
func _on_CloseBtn_pressed():

main/scn/chat_node/chat_node.tscn

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
[gd_scene load_steps=11 format=2]
1+
[gd_scene load_steps=12 format=2]
22

33
[ext_resource path="res://main/scn/buttons/normal_btn/button.gd" type="Script" id=1]
44
[ext_resource path="res://main/res/icons/050-cancel.svg" type="Texture" id=2]
55
[ext_resource path="res://main/scn/chat_node/chat_node.gd" type="Script" id=3]
66
[ext_resource path="res://main/res/icons/settings-24px.svg" type="Texture" id=4]
77
[ext_resource path="res://main/res/themes/main.tres" type="Theme" id=5]
88
[ext_resource path="res://main/res/shaders/round_avatar.tres" type="Material" id=6]
9+
[ext_resource path="res://main/res/imgs/avatar.svg" type="Texture" id=7]
910

1011
[sub_resource type="StyleBoxFlat" id=1]
1112
content_margin_left = 10.0
@@ -39,7 +40,7 @@ bg_color = Color( 0, 0, 0, 0.588235 )
3940

4041
[node name="ChatNode" type="PanelContainer"]
4142
margin_right = 300.0
42-
margin_bottom = 322.0
43+
margin_bottom = 302.0
4344
rect_min_size = Vector2( 300, 0 )
4445
size_flags_horizontal = 8
4546
size_flags_vertical = 10
@@ -54,7 +55,7 @@ __meta__ = {
5455
margin_left = 10.0
5556
margin_top = 10.0
5657
margin_right = 290.0
57-
margin_bottom = 312.0
58+
margin_bottom = 292.0
5859
custom_constants/separation = 10
5960

6061
[node name="Header" type="HBoxContainer" parent="ChatContainer"]
@@ -66,6 +67,7 @@ material = ExtResource( 6 )
6667
margin_right = 35.0
6768
margin_bottom = 35.0
6869
rect_min_size = Vector2( 35, 35 )
70+
texture = ExtResource( 7 )
6971
expand = true
7072
stretch_mode = 1
7173

@@ -117,9 +119,8 @@ color = Color( 0.913725, 0.0980392, 0.286275, 1 )
117119
[node name="History" type="ScrollContainer" parent="ChatContainer"]
118120
margin_top = 45.0
119121
margin_right = 280.0
120-
margin_bottom = 265.0
122+
margin_bottom = 245.0
121123
rect_min_size = Vector2( 0, 200 )
122-
size_flags_horizontal = 3
123124
size_flags_vertical = 3
124125
custom_styles/bg = SubResource( 2 )
125126
scroll_horizontal_enabled = false
@@ -128,15 +129,15 @@ scroll_horizontal_enabled = false
128129
margin_left = 5.0
129130
margin_top = 5.0
130131
margin_right = 275.0
131-
margin_bottom = 215.0
132+
margin_bottom = 195.0
132133
size_flags_horizontal = 3
133134
size_flags_vertical = 11
134135
custom_constants/separation = 6
135136

136137
[node name="Box" type="LineEdit" parent="ChatContainer"]
137-
margin_top = 275.0
138+
margin_top = 255.0
138139
margin_right = 280.0
139-
margin_bottom = 302.0
140+
margin_bottom = 282.0
140141

141142
[node name="Settings" type="VBoxContainer" parent="."]
142143
visible = false

main/scn/home/home.gd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ onready var chat_container : GridContainer = $AspectRatioContainer/ChatContainer
1919

2020
onready var show_post : Control = $ShowPost
2121

22+
onready var notification_lbl : Label = $HomeContainer/Menu/NotificationsBtn/Notification
23+
2224
var fr_posts : FirestoreCollection = Firebase.Firestore.collection("posts")
2325

2426
var friend_posts : Array = []
@@ -35,6 +37,7 @@ func _connect_signals():
3537
$HomeContainer/Menu/HomeBtn.connect("pressed", self, "_on_HomeBtn_pressed")
3638
$HomeContainer/Menu/ShareBtn.connect("pressed", self, "_on_ShareBtn_pressed")
3739
$HomeContainer/Menu/UsersListBtn.connect("pressed", self, "_on_UsersListBtn_pressed")
40+
$HomeContainer/Menu/NotificationsBtn.connect("pressed", self, "_on_NotificationsBtn_pressed")
3841

3942
func _ready():
4043
_connect_signals()
@@ -226,7 +229,8 @@ func _on_Name_pressed():
226229
func _on_open_post(post : PostsManager.Post):
227230
show_post.show_post(post, UsersManager.get_user_by_id(post.user_id))
228231

229-
232+
func _on_NotificationsBtn_pressed():
233+
pass
230234

231235
func _on_Home_item_rect_changed():
232236
if chat_container == null:

main/scn/home/home.tscn

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=19 format=2]
1+
[gd_scene load_steps=22 format=2]
22

33
[ext_resource path="res://main/scn/home/home.gd" type="Script" id=1]
44
[ext_resource path="res://main/res/fonts/roboto/Roboto-Black.ttf" type="DynamicFontData" id=2]
@@ -14,9 +14,20 @@
1414
[ext_resource path="res://main/res/icons/015-user-1.svg" type="Texture" id=12]
1515
[ext_resource path="res://main/scn/show_post/show_post.tscn" type="PackedScene" id=13]
1616
[ext_resource path="res://main/scn/friend_list/friend_list.tscn" type="PackedScene" id=14]
17+
[ext_resource path="res://main/res/icons/055-notification.svg" type="Texture" id=15]
1718

1819
[sub_resource type="StyleBoxEmpty" id=1]
1920

21+
[sub_resource type="StyleBoxFlat" id=5]
22+
bg_color = Color( 1, 0.352941, 0.247059, 1 )
23+
corner_radius_top_left = 40
24+
corner_radius_top_right = 40
25+
corner_radius_bottom_right = 40
26+
corner_radius_bottom_left = 40
27+
corner_detail = 20
28+
29+
[sub_resource type="DynamicFont" id=6]
30+
2031
[sub_resource type="StyleBoxEmpty" id=2]
2132

2233
[sub_resource type="DynamicFont" id=3]
@@ -122,10 +133,37 @@ texture_active = ExtResource( 12 )
122133
texture_inactive = ExtResource( 12 )
123134
color = Color( 1, 0.627451, 0.294118, 1 )
124135

125-
[node name="HSeparator2" type="HSeparator" parent="HomeContainer/Menu"]
136+
[node name="NotificationsBtn" parent="HomeContainer/Menu" instance=ExtResource( 10 )]
137+
margin_left = 15.0
126138
margin_top = 245.0
139+
margin_right = 195.0
140+
margin_bottom = 280.0
141+
rect_min_size = Vector2( 180, 30 )
142+
size_flags_horizontal = 4
143+
text = "Notifications"
144+
icon = ExtResource( 15 )
145+
texture_active = ExtResource( 15 )
146+
texture_inactive = ExtResource( 15 )
147+
color = Color( 1, 0.627451, 0.294118, 1 )
148+
149+
[node name="Notification" type="Label" parent="HomeContainer/Menu/NotificationsBtn"]
150+
visible = false
151+
margin_right = 10.0
152+
margin_bottom = 10.0
153+
rect_min_size = Vector2( 10, 10 )
154+
size_flags_horizontal = 0
155+
size_flags_vertical = 0
156+
custom_styles/normal = SubResource( 5 )
157+
custom_fonts/font = SubResource( 6 )
158+
autowrap = true
159+
__meta__ = {
160+
"_edit_use_anchors_": false
161+
}
162+
163+
[node name="HSeparator2" type="HSeparator" parent="HomeContainer/Menu"]
164+
margin_top = 295.0
127165
margin_right = 210.0
128-
margin_bottom = 255.0
166+
margin_bottom = 305.0
129167
custom_styles/separator = SubResource( 2 )
130168
custom_constants/separation = 10
131169

main/scn/message_node/received_message.tscn

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
[gd_scene load_steps=2 format=2]
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://main/scn/message_node/message.gd" type="Script" id=1]
24

35
[sub_resource type="StyleBoxFlat" id=1]
46
content_margin_left = 6.0
@@ -16,9 +18,10 @@ shadow_offset = Vector2( 0, 2 )
1618

1719
[node name="Message" type="Label"]
1820
margin_right = 13.0
19-
margin_bottom = 26.0
21+
margin_bottom = 37.0
2022
size_flags_horizontal = 0
2123
custom_styles/normal = SubResource( 1 )
24+
script = ExtResource( 1 )
2225
__meta__ = {
2326
"_edit_use_anchors_": false
2427
}
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
[gd_scene load_steps=2 format=2]
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://main/scn/message_node/message.gd" type="Script" id=1]
24

35
[sub_resource type="StyleBoxFlat" id=1]
46
content_margin_left = 6.0
57
content_margin_right = 6.0
68
content_margin_top = 6.0
79
content_margin_bottom = 6.0
8-
bg_color = Color( 1, 1, 1, 0.196078 )
10+
bg_color = Color( 0.623529, 0.623529, 0.623529, 0.470588 )
911
corner_radius_top_left = 10
1012
corner_radius_top_right = 10
1113
corner_radius_bottom_left = 10
@@ -17,12 +19,14 @@ shadow_offset = Vector2( 0, 2 )
1719
[node name="Message" type="Label"]
1820
anchor_left = 1.0
1921
anchor_right = 1.0
20-
margin_left = -9.0
21-
margin_bottom = 22.0
22+
margin_left = -13.0
23+
margin_bottom = 37.0
2224
grow_horizontal = 0
23-
size_flags_horizontal = 8
25+
size_flags_horizontal = 10
2426
custom_styles/normal = SubResource( 1 )
2527
align = 2
28+
autowrap = true
29+
script = ExtResource( 1 )
2630
__meta__ = {
2731
"_edit_use_anchors_": false
2832
}

main/scn/share/share.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func _on_AddImageBtn_pressed():
5656

5757
func _on_ShareBtn_pressed():
5858
Activities.loading(true)
59-
var share_task : FirestoreTask = RequestsManager.add_post_doc(post_description.get_text().c_escape(), image_path)
59+
var share_task : FirestoreTask = RequestsManager.add_post_doc(post_description.get_text(), image_path)
6060
var post_doc : FirestoreDocument = yield(share_task, "task_finished")
6161
if image != null:
6262
var image_task : StorageTask = RequestsManager.add_post_image(post_doc.doc_name, image_path, image.get_data().save_png_to_buffer())

project.godot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ _global_script_classes=[ {
119119
"language": "GDScript",
120120
"path": "res://main/scn/header/interactive/interactive_header.gd"
121121
}, {
122+
"base": "Label",
123+
"class": "Message",
124+
"language": "GDScript",
125+
"path": "res://main/scn/message_node/message.gd"
126+
}, {
122127
"base": "PanelContainer",
123128
"class": "PostContainer",
124129
"language": "GDScript",
@@ -162,6 +167,7 @@ _global_script_class_icons={
162167
"FirestoreTileMap": "",
163168
"FriendButton": "",
164169
"InteractiveHeader": "",
170+
"Message": "",
165171
"PostContainer": "",
166172
"StorageReference": "",
167173
"StorageTask": "",

0 commit comments

Comments
 (0)