This repository has been archived by the owner on Sep 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.qml
95 lines (85 loc) · 2.51 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import QtQuick 2.3
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import me.mnafees 1.0
Window {
visible: true
width: 300
height: 300
Facebook {
id: facebook
readPermissions: ["public_profile", "email", "user_friends"]
publishPermissions: ["publish_actions"]
// Callbacks
onLoginSuccess: {
showUserInfo()
shareButton.visible = true
loginButton.text = "Logout"
console.log("Login successful")
}
onLoginError: {
console.log("Login error")
}
onLoginCancel: {
console.log("Login canceled")
}
onShareSuccess: {
console.log("Share successful")
}
onShareError: {
console.log("Share error")
}
onShareCancel: {
console.log("Share canceled")
}
}
Button {
id: shareButton
anchors.bottom: loginButton.top
anchors.horizontalCenter: parent.horizontalCenter
text: "Share on Facebook"
visible: false
onClicked: {
if (facebook.isLoggedIn()) {
facebook.share("Test", "Test", "https://github.com/mnafees", facebook.getProfilePictureUri(200, 200))
}
}
}
Button {
id: loginButton
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
text: "Login with Facebook"
onClicked: {
if (facebook.isLoggedIn()) {
facebook.logout()
shareButton.visible = false
loginButton.text = "Login with Facebook"
} else {
facebook.login()
}
/**
* Other valid method calls
*
* facebook.share("title", "text", "url", "imageUrl")
* facebook.getProfileId()
* facebook.getProfileLinkUri()
* facebook.getProfileName()
* facebook.getProfilePictureUri(200, 200) */
}
}
function showUserInfo() {
console.log(facebook.getProfileId())
console.log(facebook.getProfileLinkUri())
console.log(facebook.getProfileName())
console.log(facebook.getProfilePictureUri(200, 200))
}
Component.onCompleted: {
if (facebook.isLoggedIn()) {
shareButton.visible = true
loginButton.text = "Logout"
showUserInfo()
}
}
}