Skip to content

Commit e8aef32

Browse files
committed
update v1.4
1 parent 70f84bb commit e8aef32

19 files changed

+394
-37
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/arrow_forward_white_36dp.svg-cb2cb7d977307fbf655b2957efd450db.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://main/res/icons/arrow_forward_white_36dp.svg"
13+
dest_files=[ "res://.import/arrow_forward_white_36dp.svg-cb2cb7d977307fbf655b2957efd450db.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

main/scn/app/main.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func _on_show_error(error : String):
6464

6565
# ..... top bar signals
6666
func _on_TopBar_close():
67+
UserData.is_logged = false
68+
UserData.last_logged = OS.get_datetime()
69+
loading.set_loading(true)
70+
yield(RequestsManager.update_user(), "task_finished")
6771
get_tree().quit()
6872

6973
func _on_TopBar_minimize():

main/scn/header/header.gd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
extends HBoxContainer
22

3+
signal pressed(user_id, user_name)
4+
5+
var user_id : String
36
var user_name : String
47
var user_picture : ImageTexture
58

@@ -20,9 +23,11 @@ func load_from_user(user_obj : UsersManager.User):
2023
user_obj.connect("update_picture", self, "set_picture")
2124
set_picture(user_obj.picture)
2225
set_user_name(user_obj.username)
26+
user_id = user_obj.id
2327

2428
func load_from_document(document : FirestoreDocument):
2529
set_user_name(document.doc_fields.username)
30+
user_id = document.doc_fields.localid
2631

2732
func set_picture(picture : ImageTexture):
2833
user_picture = picture
@@ -33,3 +38,7 @@ func set_picture(picture : ImageTexture):
3338
func set_user_name(_name : String):
3439
user_name = _name
3540
$Name.set_text(_name)
41+
42+
43+
func _on_Name_pressed() -> void:
44+
emit_signal("pressed", user_id, user_name)

main/scn/header/header.tscn

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
margin_right = 168.0
99
margin_bottom = 60.0
1010
size_flags_vertical = 4
11+
custom_constants/separation = 15
1112
script = ExtResource( 3 )
1213
__meta__ = {
1314
"_edit_use_anchors_": false
@@ -24,9 +25,11 @@ expand = true
2425
stretch_mode = 1
2526

2627
[node name="Name" type="LinkButton" parent="."]
27-
margin_left = 68.0
28+
margin_left = 75.0
2829
margin_top = 17.0
29-
margin_right = 116.0
30+
margin_right = 123.0
3031
margin_bottom = 42.0
3132
size_flags_vertical = 4
3233
text = "user"
34+
35+
[connection signal="pressed" from="Name" to="." method="_on_Name_pressed"]

main/scn/header/interactive/interactive_header.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func _on_ConnecBtn_pressed():
6464
yield(friend_task, "update_document")
6565
if check_friend():
6666
emit_signal("connected", user, $ConnecBtn)
67+
RequestsManager.send_notification(UserData.user_id, user_id, "connect")
6768
else:
6869
emit_signal("disconnect", user)
6970

main/scn/home/home.gd

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ onready var posts_section : VBoxContainer = sections_container.get_node("Posts")
88
onready var users_list_section : VBoxContainer = sections_container.get_node("UsersList")
99
onready var settings_section : VBoxContainer = sections_container.get_node("Settings")
1010
onready var profile_section : VBoxContainer = sections_container.get_node("Profile")
11+
onready var notifications_section : VBoxContainer = sections_container.get_node("Notifications")
1112

1213
onready var post_box : VBoxContainer = posts_section.get_node("ScrollPost/PostContainer")
1314
onready var profile_post_container : VBoxContainer = profile_section.get_node("ScrollPost/PostContainer")
@@ -16,18 +17,19 @@ onready var menu : VBoxContainer = $HomeContainer/Menu
1617
onready var side_bar : VBoxContainer = $HomeContainer/SideBar
1718
onready var friend_list : VBoxContainer = side_bar.get_node("FriendList")
1819

20+
onready var notification_lbl : Label = $HomeContainer/Menu/NotificationsBtn/Notification
1921

2022
onready var chat_container : GridContainer = $AspectRatioContainer/ChatContainer
2123

2224
onready var show_post : Control = $ShowPost
2325

24-
onready var notification_lbl : Label = $HomeContainer/Menu/NotificationsBtn/Notification
2526

2627
var fr_posts : FirestoreCollection = Firebase.Firestore.collection("posts")
2728

2829
var friend_posts : Array = []
2930

3031
var posts_db_reference : FirebaseDatabaseReference
32+
var notifications_db_reference : FirebaseDatabaseReference
3133

3234
var window_size : Vector2
3335

@@ -43,6 +45,8 @@ func _connect_signals():
4345
$HomeContainer/Menu/UsersListBtn.connect("pressed", self, "_on_UsersListBtn_pressed")
4446
$HomeContainer/Menu/NotificationsBtn.connect("pressed", self, "_on_NotificationsBtn_pressed")
4547
$HomeContainer/Menu/SettingsBtn.connect("pressed", self, "_on_SettingsBtn_pressed")
48+
49+
notifications_section.connect("visibility_changed", self, "_on_notification_section_visibility")
4650

4751
func _ready():
4852
_connect_signals()
@@ -57,8 +61,7 @@ func _ready():
5761
animate_Home(true)
5862
load_posts()
5963
friend_list.load_friend_list()
60-
61-
64+
connect_notifications()
6265

6366
func animate_Home(display : bool):
6467
if display:
@@ -100,6 +103,14 @@ func load_posts():
100103
posts_db_reference = Firebase.Database.get_database_reference("sociadot/posts")
101104
posts_db_reference.connect("new_data_update", self, "_on_new_post")
102105

106+
func connect_notifications() -> void:
107+
notifications_db_reference = Firebase.Database.get_database_reference("sociadot/notifications/"+UserData.user_id)
108+
notifications_db_reference.connect("new_data_update", self, "_on_new_notification")
109+
110+
func _on_new_notification(notification : FirebaseResource):
111+
notifications_section.manage_notification(notification)
112+
if not notification.data.viewed:
113+
notification_lbl.show()
103114

104115
func check_friend_posts_list(post_doc : FirestoreDocument) -> bool:
105116
for post in friend_posts:
@@ -231,7 +242,12 @@ func _on_open_post(post : PostsManager.Post):
231242
show_post.show_post(post, UsersManager.get_user_by_id(post.user_id))
232243

233244
func _on_NotificationsBtn_pressed():
234-
pass
245+
show_section(notifications_section)
246+
notification_lbl.hide()
247+
248+
func _on_notification_section_visibility():
249+
if not notifications_section.visible:
250+
notifications_section.view_notifications()
235251

236252
func _on_Home_item_rect_changed():
237253
update_chat_container()

main/scn/home/home.tscn

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,16 @@
1313
[ext_resource path="res://main/scn/profile/profile.tscn" type="PackedScene" id=11]
1414
[ext_resource path="res://main/res/icons/notifications_none_white_24dp.svg" type="Texture" id=12]
1515
[ext_resource path="res://main/scn/show_post/show_post.tscn" type="PackedScene" id=13]
16+
[ext_resource path="res://main/scn/notifications/notifications.gd" type="Script" id=14]
1617
[ext_resource path="res://main/res/icons/groups_white_24dp.svg" type="Texture" id=15]
1718
[ext_resource path="res://main/res/icons/settings-24px.svg" type="Texture" id=16]
1819
[ext_resource path="res://main/scn/settings/settings.tscn" type="PackedScene" id=17]
20+
[ext_resource path="res://main/scn/labels_icons/color_round_s.tscn" type="PackedScene" id=18]
1921

2022
[sub_resource type="StyleBoxEmpty" id=1]
2123

2224
[sub_resource type="StyleBoxEmpty" id=2]
2325

24-
[sub_resource type="StyleBoxFlat" id=3]
25-
bg_color = Color( 1, 0.352941, 0.247059, 1 )
26-
corner_radius_top_left = 40
27-
corner_radius_top_right = 40
28-
corner_radius_bottom_right = 40
29-
corner_radius_bottom_left = 40
30-
corner_detail = 20
31-
32-
[sub_resource type="DynamicFont" id=4]
33-
3426
[sub_resource type="DynamicFont" id=5]
3527
size = 25
3628
font_data = ExtResource( 2 )
@@ -136,19 +128,7 @@ texture_active = ExtResource( 12 )
136128
texture_inactive = ExtResource( 12 )
137129
color = Color( 1, 0.627451, 0.294118, 1 )
138130

139-
[node name="Notification" type="Label" parent="HomeContainer/Menu/NotificationsBtn"]
140-
visible = false
141-
margin_right = 10.0
142-
margin_bottom = 10.0
143-
rect_min_size = Vector2( 10, 10 )
144-
size_flags_horizontal = 0
145-
size_flags_vertical = 0
146-
custom_styles/normal = SubResource( 3 )
147-
custom_fonts/font = SubResource( 4 )
148-
autowrap = true
149-
__meta__ = {
150-
"_edit_use_anchors_": false
151-
}
131+
[node name="Notification" parent="HomeContainer/Menu/NotificationsBtn" instance=ExtResource( 18 )]
152132

153133
[node name="SettingsBtn" parent="HomeContainer/Menu" instance=ExtResource( 10 )]
154134
margin_left = 15.0
@@ -223,6 +203,42 @@ size_flags_horizontal = 3
223203
size_flags_vertical = 3
224204
custom_constants/separation = 30
225205

206+
[node name="Notifications" type="VBoxContainer" parent="HomeContainer/Sections"]
207+
visible = false
208+
margin_top = 302.0
209+
margin_right = 564.0
210+
margin_bottom = 600.0
211+
size_flags_vertical = 3
212+
script = ExtResource( 14 )
213+
__meta__ = {
214+
"_edit_use_anchors_": false
215+
}
216+
217+
[node name="Label" type="Label" parent="HomeContainer/Sections/Notifications"]
218+
margin_right = 564.0
219+
margin_bottom = 39.0
220+
custom_fonts/font = SubResource( 5 )
221+
text = "Notifications"
222+
align = 1
223+
224+
[node name="ScrollNotifications" type="ScrollContainer" parent="HomeContainer/Sections/Notifications"]
225+
margin_top = 43.0
226+
margin_right = 564.0
227+
margin_bottom = 298.0
228+
size_flags_horizontal = 3
229+
size_flags_vertical = 3
230+
custom_styles/bg = SubResource( 6 )
231+
scroll_horizontal_enabled = false
232+
233+
[node name="NotificationsContainer" type="VBoxContainer" parent="HomeContainer/Sections/Notifications/ScrollNotifications"]
234+
margin_left = 10.0
235+
margin_top = 10.0
236+
margin_right = 554.0
237+
margin_bottom = 245.0
238+
size_flags_horizontal = 3
239+
size_flags_vertical = 3
240+
custom_constants/separation = 5
241+
226242
[node name="Profile" parent="HomeContainer/Sections" instance=ExtResource( 11 )]
227243
visible = false
228244
anchor_right = 0.0
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[sub_resource type="StyleBoxFlat" id=1]
4+
bg_color = Color( 1, 0.352941, 0.247059, 1 )
5+
corner_radius_top_left = 40
6+
corner_radius_top_right = 40
7+
corner_radius_bottom_right = 40
8+
corner_radius_bottom_left = 40
9+
corner_detail = 20
10+
11+
[sub_resource type="DynamicFont" id=2]
12+
13+
[node name="Notification" type="Label"]
14+
visible = false
15+
margin_right = 10.0
16+
margin_bottom = 10.0
17+
rect_min_size = Vector2( 10, 10 )
18+
size_flags_horizontal = 0
19+
size_flags_vertical = 0
20+
custom_styles/normal = SubResource( 1 )
21+
custom_fonts/font = SubResource( 2 )
22+
autowrap = true
23+
__meta__ = {
24+
"_edit_use_anchors_": false
25+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
extends PanelContainer
2+
class_name Notification
3+
4+
signal header_pressed(user_id, user_name)
5+
signal show_post(post)
6+
signal show_post_comment(post, comment_id)
7+
8+
export (Dictionary) var actions : Dictionary = {}
9+
10+
onready var content_lbl : Label = $Container/Header/Content
11+
onready var icon : TextureRect = $Container/Icon
12+
onready var user_header : HBoxContainer = $Container/Header/UserHeader
13+
onready var go_to : ToolButton = $Container/GoTo
14+
15+
var id : String
16+
var user_id : String
17+
var action : String
18+
var viewed : bool setget set_viewed
19+
var source : Dictionary
20+
21+
func _connect_signals() -> void:
22+
user_header.connect("pressed", self, "_on_header_pressed")
23+
go_to.connect("pressed", self, "goto_pressed")
24+
25+
func _ready() -> void:
26+
hide()
27+
_connect_signals()
28+
29+
func load_notification(resource : FirebaseResource) -> void:
30+
self.id = resource.key
31+
self.user_id = resource.data.user
32+
self.action = resource.data.action
33+
if resource.data.has("source"):
34+
self.source = resource.data.source
35+
go_to.show()
36+
set_viewed(resource.data.viewed)
37+
var user : UsersManager.User = UsersManager.get_user_by_id(user_id)
38+
if user == null:
39+
user = UsersManager.add_user(user_id, RequestsManager.get_user(user_id), RequestsManager.get_profile_picture(user_id))
40+
user_header.load_from_user(user)
41+
icon.set_texture(actions[action])
42+
content_lbl.set_text(action2content(action))
43+
show()
44+
45+
func set_viewed(v : bool) -> void:
46+
viewed = v
47+
$Container/Notification.visible = not viewed
48+
modulate.a = 1 - (int(viewed) - 0.7)
49+
50+
func action2content(action : String) -> String:
51+
match action:
52+
"connect":
53+
icon.modulate = Color.royalblue
54+
return "Wants to connect with you!"
55+
"comment":
56+
icon.modulate = Color.cadetblue
57+
return "Commented your post!"
58+
"like":
59+
icon.modulate = Color.mediumvioletred
60+
return "Liked your post!"
61+
_:
62+
return ""
63+
64+
func _on_header_pressed(user_id : String, user_name : String):
65+
emit_signal("header_pressed", user_id, user_name)
66+
67+
func goto_pressed():
68+
match action:
69+
"like":
70+
var post : PostsManager.Post = PostsManager.get_post_by_id(source.post_id)
71+
if post == null:
72+
post = PostsManager.add_post_from_doc(source.post_id, yield(RequestsManager.get_post_doc(source.post_id), "get_document"))
73+
emit_signal("show_post", post)
74+
"comment":
75+
emit_signal("show_post_comment", source.post_id, source.comment_id)

0 commit comments

Comments
 (0)