Skip to content

Commit

Permalink
Manage code and Snakbar removed
Browse files Browse the repository at this point in the history
  • Loading branch information
WithSJ committed Jan 4, 2021
1 parent 376d097 commit fc6988a
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 198 deletions.
61 changes: 59 additions & 2 deletions libs/uix/baseclass/chat_room.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
from main_imports import MDScreen
from main_imports import MDScreen,MDCard,MDLabel,MDSeparator
from libs.applibs import utils

utils.load_kv("chat_room.kv")

class Chat_Room_Screen(MDScreen):
pass

def chat_textbox(self):
"""
MDCard size change when MSGbox use multilines.
MDCard y axis size incress when MSGbox y axis size incress
"""
fixed_Y_size = self.ids.root_chatroom.size[1]/3
msg_textbox=self.ids.msg_textbox.size

if msg_textbox[1] <= fixed_Y_size:

self.ids.send_card.size[1]=msg_textbox[1]
print(msg_textbox)
else:
self.ids.send_card.size[1]=fixed_Y_size

def send_msg(self,msg_data):
"""
When send button use to send msg this function call
and clear MSGbox
"""

text_msg = MDLabel(text=msg_data,halign="left")

sizeX = self.ids.msg_textbox.size[0]

sizeY = self.ids.msg_textbox.size[1]+60
# ->> sizeY is equal to msg_textbox sizeY because text_msg sizeY not work
# that's why i use msg_textbox is called 'Jugaad'


msg_card= MDCard(
orientation= "vertical",
size_hint=[None,None],
size=[sizeX,sizeY],
spacing=8,
padding=20,
elevation=9,
ripple_behavior= True,
radius= [25,25,25,0 ]

)
msg_card.add_widget(MDLabel(
text= f"Hamster {' '*8} |1:00 PM|",
theme_text_color= "Secondary",
size_hint_y= None,
height= 50
))
msg_card.add_widget(MDSeparator(
height= "1dp"
))

msg_card.add_widget(text_msg)
self.ids.all_msgs.add_widget(msg_card)
print(msg_data)
self.ids.msg_scroll_view.scroll_to(msg_card)
self.ids.msg_textbox.text=""

21 changes: 19 additions & 2 deletions libs/uix/baseclass/home.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
from main_imports import MDScreen
from main_imports import MDScreen,TwoLineAvatarListItem,ImageLeftWidget
from libs.applibs import utils

utils.load_kv("home.kv")

class Home_Screen(MDScreen):
pass

def search_account(self,search_field):
"""
this method use when search button pressed search_field
contain data in string that you want to search on hamster server
"""

# for dummy search item [------

twolineW= TwoLineAvatarListItem(text=f"{search_field}",
secondary_text=f"@{search_field}")

twolineW.add_widget(ImageLeftWidget(source="hamster_icon.png"))

self.ids.search_items.add_widget(twolineW)
# # ----- ] end dummy search


59 changes: 57 additions & 2 deletions libs/uix/baseclass/profile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,62 @@
from main_imports import MDScreen
from main_imports import MDScreen,MDGridBottomSheet,OneLineTextDialog,MDDialog,MDFlatButton
from libs.applibs import utils

utils.load_kv("profile.kv")

class Profile_Screen(MDScreen):
pass

def change_profile_data(self,widget):
"""Change text data using Dialog box.
[widget] change this widget text"""
dialogObj =None
Dialog=OneLineTextDialog()
def cancel_btn(btn):
# use function when CANCEL btn click
dialogObj.dismiss(force=True)
def ok_btn(btn):
# use function when OK btn click
widget.text = Dialog.ids.dialog_text.text
cancel_btn(btn)


if not dialogObj:
dialogObj=MDDialog(
auto_dismiss=True,
title= widget.secondary_text,
type="custom",
content_cls=Dialog,
buttons=[
MDFlatButton(
text="CANCEL",
# text_color=self.theme_cls.primary_color,
on_release=cancel_btn,
),
MDFlatButton(
text="OK",
# text_color=self.theme_cls.primary_color,
on_release=ok_btn,
),
],
)
dialogObj.open()


def change_profile_img(self):
"""
method call when image click on profile_view page.
if it's user own profile than show options of change.
"""
bottom_sheet_menu = MDGridBottomSheet(
animation=True,
)
data = {
"Upload": "cloud-upload",
"Camera": "camera",
}
for item in data.items():
bottom_sheet_menu.add_item(
item[0],
lambda x, y=item[0]: print("hello",x,y),
icon_src=item[1],
)
bottom_sheet_menu.open()
46 changes: 44 additions & 2 deletions libs/uix/baseclass/root.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
from main_imports import ScreenManager
from libs.applibs import utils

from kivy.core.window import Window
utils.load_kv("root.kv")

class Root(ScreenManager):
pass
def __init__(self, **kwargs):
super(Root, self).__init__(**kwargs)
Window.bind(on_keyboard=self._key_handler)
self.screen_list = list() #this list have all screen that user switched

def _key_handler(self, instance, key, *args):

if key is 27:
#in Desktop this key 27 is Esc and in Phone it's Back btn
self.previous_screen()
return True

def previous_screen(self):
"""
Switch to previous screen last screen in screen_list
"""
last_screen=self.screen_list.pop()
if last_screen == "home" or last_screen == "login":
exit()
print(self.screen_list)
self.transition.direction = "left"
self.current = self.screen_list[len(self.screen_list)-1]




def change_screen(self,name):
"""
Switch Screen using screen name and
"""
self.current = name
if name not in self.screen_list:
self.screen_list.append(self.current)
else:
self.screen_list.remove(name)
self.screen_list.append(self.current)

print(self.screen_list)

if name == "home":
# MDBottomNavigation not resize there tabs when app stat in android
# to resize when switch to home screen
self.get_screen(name).ids.android_tabs.on_resize()
6 changes: 3 additions & 3 deletions libs/uix/kv/chat_room.kv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
id:profile_bar
title: "@username"
size_hint: 1,0.08
left_action_items: [ ["arrow-left", lambda x:app.change_screen("home")]]
left_action_items: [ ["arrow-left", lambda x:app.screen_manager.change_screen("home")]]
elevation: 5
MDBoxLayout:
# md_bg_color: app.theme_cls.primary_color
Expand Down Expand Up @@ -40,12 +40,12 @@
id:msg_textbox
multiline: True
max_text_length: 250
on_text: app.chat_textbox()
on_text: root.chat_textbox()


MDIconButton:
icon:"send"
on_release: app.send_msg(msg_textbox.text)
on_release: root.send_msg(msg_textbox.text)



6 changes: 3 additions & 3 deletions libs/uix/kv/forgot.kv
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
text: "Forgot Password"
pos_hint: {"center_x": 0.5, "center_y":0.5}
size_hint: .7,0.05
on_release: app.change_screen("verification")
on_release: app.screen_manager.change_screen("verification")

MDTextButton:
text: f"[color=#000000]Don't have an account?[/color] Sign up"
markup: True
pos_hint: {"center_x":0.5, "center_y":0.4}
on_release: app.change_screen("signup")
on_release: app.screen_manager.change_screen("signup")

MDTextButton:
text: f"[b][color=#000000]Back To[/color] Login[/b]"
markup: True
pos_hint: {"center_x":0.5, "center_y":0.33}
on_release: app.change_screen("login")
on_release: app.screen_manager.change_screen("login")

MDLabel:
text: f"[font=Icons] {md_icons['copyright']}[/font] [font=Roboto]{COMPANY_NAME} 2020[/font]"
Expand Down
4 changes: 2 additions & 2 deletions libs/uix/kv/home.kv
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
MDToolbar:
title: APP_NAME
size_hint: 1,.08
right_action_items: [ ["account", lambda x:app.change_screen("profile")]]
right_action_items: [ ["account", lambda x:app.screen_manager.change_screen("profile")]]
elevation: 5

MDBottomNavigation:
Expand Down Expand Up @@ -42,7 +42,7 @@

MDIconButton:
icon: 'magnify'
on_release: app.search_account(search_field.text)
on_release: root.search_account(search_field.text)

ScrollView:
MDList:
Expand Down
6 changes: 3 additions & 3 deletions libs/uix/kv/login.kv
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
text: "Login"
pos_hint: {"center_x": 0.5, "center_y":0.48}
size_hint: .7,0.05
on_release: app.change_screen("home")
on_release: app.screen_manager.change_screen("home")

MDTextButton:
text: "Forgot password?"
pos_hint: {"center_x":0.5, "center_y":0.4}
on_release: app.change_screen("forgot")
on_release: app.screen_manager.change_screen("forgot")

MDTextButton:
text: f"[color=#000000]Don't have an account?[/color] Sign up"
markup: True
pos_hint: {"center_x":0.5, "center_y":0.33}
on_release: app.change_screen("signup")
on_release: app.screen_manager.change_screen("signup")

MDLabel:
text: f"[font=Icons] {md_icons['copyright']}[/font] [font=Roboto]{COMPANY_NAME} 2020[/font]"
Expand Down
12 changes: 4 additions & 8 deletions libs/uix/kv/profile.kv
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

#:import Snackbar kivymd.uix.snackbar.Snackbar

<Profile_Screen>:
name: "profile"
MDBoxLayout:
Expand All @@ -12,7 +9,7 @@
title: "Profile"
size_hint: 1,0.08
# pos_hint: {"center_y":.965}
left_action_items: [ ["arrow-left", lambda x:app.change_screen("home")]]
left_action_items: [ ["arrow-left", lambda x:app.screen_manager.change_screen("home")]]
elevation: 5

MDBoxLayout:
Expand All @@ -29,7 +26,7 @@
id:profile_image
background_normal: "profile.jpg"
background_down: "profile.jpg"
on_release: app.change_profile_img()
on_release: root.change_profile_img()


MDList:
Expand All @@ -44,7 +41,7 @@

IconRightWidget:
icon: "pen"
on_release: app.change_text_data(profile_name)
on_release: root.change_profile_data(profile_name)

TwoLineAvatarIconListItem:
id:profile_username
Expand All @@ -55,7 +52,6 @@

IconRightWidget:
icon: "pen-lock"
on_release: Snackbar(text="You can't change username.").open()
# on_release: app.change_text_data(profile_username)

TwoLineAvatarIconListItem:
Expand All @@ -68,4 +64,4 @@

IconRightWidget:
icon: "pen"
on_release: app.change_text_data(profile_email)
on_release: root.change_profile_data(profile_email)
2 changes: 1 addition & 1 deletion libs/uix/kv/signup.kv
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
text: f"[color=#000000]Have an account?[/color] Log in"
markup: True
pos_hint: {"center_x":0.5, "center_y":0.22}
on_release: app.change_screen("login")
on_release: app.screen_manager.change_screen("login")

MDLabel:
text: f"[font=Icons] {md_icons['copyright']}[/font] [font=Roboto]{COMPANY_NAME} 2020[/font]"
Expand Down
2 changes: 1 addition & 1 deletion libs/uix/kv/verification.kv
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
MDTextButton:
text: "Resend code"
pos_hint: {"center_x": 0.5, "center_y":0.45}
on_release: app.change_screen("verification")
on_release: app.screen_manager.change_screen("verification")

MDLabel:
text: "Never share your verification code to anyone."
Expand Down
Loading

0 comments on commit fc6988a

Please sign in to comment.