ionic-Material Design , Codecanyon
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<!--View Information-->
|
||||
<!--View name : google Plus Feed-->
|
||||
<!--Controller name : googlePlusFeedCtrl-->
|
||||
<!--Controller path : www/templates/social-network-connect/google-plus/js/controllers.js-->
|
||||
<!--State name : app.googlePlusFeed-->
|
||||
<!--URL : #app/googlePlusFeed-->
|
||||
|
||||
<ion-view view-title="Google feed">
|
||||
<!--left button on navigation bar-->
|
||||
<ion-nav-buttons side="left">
|
||||
<a ng-click="$ionicGoBack()" class="button back-button buttons button-clear header-item nav-back-btn">
|
||||
<i class="ion-android-arrow-back"></i>
|
||||
</a>
|
||||
</ion-nav-buttons><!--end left button on navigation bar-->
|
||||
|
||||
<!--social feed content section-->
|
||||
<ion-content id="social-feed-content">
|
||||
|
||||
<ion-refresher pulling-text="Pull to refresh..." on-refresh="doRefresh()">
|
||||
</ion-refresher>
|
||||
|
||||
<ion-list>
|
||||
|
||||
<!--social card section-->
|
||||
<md-card ng-repeat="item in feedList" class="social-card">
|
||||
<md-card-content>
|
||||
<md-list-item class="md-2-line md-no-proxy" role="listitem">
|
||||
<img ng-src="{{item.actor.image.url}}"
|
||||
class="md-avatar">
|
||||
|
||||
<div class="md-list-item-text">
|
||||
<h3>{{item.actor.displayName}}</h3>
|
||||
|
||||
<p>{{item.published | date:"short" }}</p>
|
||||
</div>
|
||||
</md-list-item>
|
||||
<p>{{item.title}}</p>
|
||||
</md-card-content>
|
||||
<!--social card image section-->
|
||||
<div class="social-card-image">
|
||||
<img ng-src="{{item.object.attachments[0].image.url}}"
|
||||
ng-show="item.object.attachments[0].image.url != null ? true : false"
|
||||
class="ng-hide">
|
||||
</div><!--end social card image section-->
|
||||
|
||||
<!--social card footer section-->
|
||||
<div class="social-card-footer">
|
||||
<div class="row-content" layout="row">
|
||||
<div class="col-33">
|
||||
{{item.object.plusoners.totalItems | numberSuffix}} <span> Likes</span>
|
||||
</div>
|
||||
<div class="col-33">
|
||||
{{item.object.replies.totalItems | numberSuffix}} <span>Comments</span>
|
||||
</div>
|
||||
<div class="col-33">
|
||||
{{item.object.resharers.totalItems | numberSuffix}} <span>Shared</span>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--end social card footer section-->
|
||||
</md-card><!--end social card section-->
|
||||
|
||||
<ion-infinite-scroll ng-if="!paging.shouldLoadData" on-infinite="loadMore()" distance="1%">
|
||||
</ion-infinite-scroll>
|
||||
|
||||
</ion-content><!--end social feed content section-->
|
||||
</ion-view>
|
||||
@@ -0,0 +1,41 @@
|
||||
<!--View Information-->
|
||||
<!--View name : google Plus Login-->
|
||||
<!--Controller name : googlePlusLoginCtrl-->
|
||||
<!--Controller path : www/templates/social-network-connect/google-plus/js/controllers.js-->
|
||||
<!--State name : app.googlePlusLogin-->
|
||||
<!--URL : #app/googlePlusLogin-->
|
||||
|
||||
<ion-view title="Google Plus Connect">
|
||||
<!--login content section-->
|
||||
<ion-content scroll="false" id="social-login">
|
||||
<form>
|
||||
|
||||
<div>
|
||||
<i class="fa fa-google-plus google-plus-color"></i>
|
||||
</div>
|
||||
<div class="sub-header">Connect data with google plus.</div>
|
||||
|
||||
<div class="ng-hide" ng-show="isLogin">
|
||||
<a class="md-raised social-button md-button md-default-theme google-plus-color-background"
|
||||
ng-click="goToUserProfile()">
|
||||
GO TO GOOGLE PLUS APP
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="ng-hide" ng-show="!isLogin">
|
||||
<a class="md-raised social-button md-button md-default-theme google-plus-color-background"
|
||||
ng-click="login()">
|
||||
LOG IN WITH GOOGLE PLUS
|
||||
</a>
|
||||
<br/>
|
||||
<a href="#/app/fakeSignUp" class="md-raised md-button md-default-theme social-default-button">SIGN
|
||||
UP</a>
|
||||
<a href="#/app/tryApp" class="md-raised md-button md-default-theme social-default-button">TRY APP</a>
|
||||
|
||||
<div class="footer">Already have an account? <a href="#/app/fakeLogin">Sign In</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</ion-content><!--end login content section-->
|
||||
</ion-view>
|
||||
@@ -0,0 +1,85 @@
|
||||
<!--View Information-->
|
||||
<!--View name : google Plus Profile-->
|
||||
<!--Controller name : googlePlusProfileCtrl-->
|
||||
<!--Controller path : www/templates/social-network-connect/google-plus/js/controllers.js-->
|
||||
<!--State name : app.googlePlusProfile-->
|
||||
<!--URL : #app/googlePlusProfile-->
|
||||
|
||||
<ion-view title="Social">
|
||||
<!--left button on navigation bar-->
|
||||
<ion-nav-buttons side="left">
|
||||
<a ng-click="$ionicGoBack()" class="button back-button buttons button-clear header-item nav-back-btn">
|
||||
<i class="ion-android-arrow-back"></i>
|
||||
</a>
|
||||
</ion-nav-buttons><!--end left button on navigation bar-->
|
||||
|
||||
<ion-content>
|
||||
<div class="toolbar-image-cover" style="background-image: url('{{userInfo.pictureProfileUrl}}');"></div>
|
||||
<md-tabs class="ng-hide" ng-show="!loading" md-dynamic-height md-border-bottom>
|
||||
<md-tab label="Profile">
|
||||
<!--social profile content section-->
|
||||
<md-content id="social-profile-content" class="md-padding">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-33">
|
||||
<i class="ion-card"></i>
|
||||
</div>
|
||||
<div class="col-66">{{userInfo.id}}</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-33">
|
||||
<i class="ion-android-person"></i>
|
||||
</div>
|
||||
<div class="col-66">{{userInfo.name}}</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-33">
|
||||
<i class="fa fa-circle-thin"></i>
|
||||
</div>
|
||||
<div class="col-66">{{userInfo.gender}}</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-33">
|
||||
<i class="ion-android-mail"></i>
|
||||
</div>
|
||||
<div class="col-66">{{userInfo.email}}</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-33">
|
||||
<i class="ion-link"></i>
|
||||
</div>
|
||||
<div class="col-66">{{userInfo.link}}</div>
|
||||
</div>
|
||||
|
||||
</md-content><!--end social profile content section-->
|
||||
</md-tab>
|
||||
<md-tab label="More">
|
||||
<md-content class="md-padding">
|
||||
<!--list section-->
|
||||
<md-list>
|
||||
<md-subheader class="google-plus-color">More Google Plus APIs.</md-subheader>
|
||||
<md-list-item class="md-list-item-default"
|
||||
ng-click="navigateTo('app.googlePlusFeed')">
|
||||
<i class="ion-android-list"></i>
|
||||
|
||||
<p>View Feed</p>
|
||||
</md-list-item>
|
||||
<md-list-item class="md-list-item-default" ng-click="logOut($event)">
|
||||
<i class="ion-locked"></i>
|
||||
|
||||
<p>Log Out</p>
|
||||
</md-list-item>
|
||||
</md-list><!--end list section-->
|
||||
</md-content>
|
||||
</md-tab>
|
||||
</md-tabs>
|
||||
<!--social loading progress section-->
|
||||
<md-progress-circular ng-show="loading" class="md-warn md-progress-social-profile ng-hide"
|
||||
md-mode="indeterminate"></md-progress-circular><!--end social loading progress section-->
|
||||
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
@@ -0,0 +1,326 @@
|
||||
// For connecting with google you have to install $cordovaOauth by running the following
|
||||
// command in your cmd.exe for windows or terminal for mac:
|
||||
// $ cd your_project_path
|
||||
// $ ionic plugin remove org.apache.cordova.inappbrowser
|
||||
// $ ionic plugin add org.apache.cordova.inappbrowser
|
||||
//
|
||||
// Learn more about $cordovaOauth :
|
||||
// http://ngcordova.com/docs/plugins/oauth/
|
||||
//
|
||||
// object schema of google plus profile that keep in localStorage is:
|
||||
// [{
|
||||
// name: google plus name,
|
||||
// email: email,
|
||||
// link: google plus link,
|
||||
// pictureProfileUrl: google plus profile url,
|
||||
// gender: gender,
|
||||
// id: google plus id,
|
||||
// access_token: access_token
|
||||
// }]
|
||||
//
|
||||
// Controller of google plus login Page.
|
||||
appControllers.controller('googlePlusLoginCtrl', function ($scope, $state, $cordovaOauth, $http, localStorage) {
|
||||
|
||||
// This function is the first activity in the controller.
|
||||
// It will initial all variable data and let the function works when page load.
|
||||
$scope.initialForm = function () {
|
||||
|
||||
// $scope.isLogin is the variable for check that user is login or not.
|
||||
$scope.isLogin = false;
|
||||
|
||||
// $scope.isLoading is the variable for loading progress.
|
||||
$scope.isLoading = false;
|
||||
|
||||
// $scope.userInfo is the variable that store user information data.
|
||||
$scope.userInfo = {
|
||||
name: "",
|
||||
email: "",
|
||||
link: "",
|
||||
pictureProfileUrl: "",
|
||||
gender: "",
|
||||
id: "",
|
||||
access_token: ""
|
||||
};
|
||||
|
||||
// Getting user information.
|
||||
$scope.userInfo = $scope.getUserProfile();
|
||||
};// End initialForm.
|
||||
|
||||
// navigateTo is for navigate to other page
|
||||
// by using targetPage to be the destination page.
|
||||
// Parameter :
|
||||
// targetPage = destination page.
|
||||
$scope.navigateTo = function (targetPage) {
|
||||
$state.go(targetPage);
|
||||
};// End navigateTo.
|
||||
|
||||
// goToUserProfile is for navigate to Google Plus Profile page.
|
||||
$scope.goToUserProfile = function () {
|
||||
if ($scope.isLoading == false) {
|
||||
$scope.isLoading = true;
|
||||
$scope.navigateTo('app.googlePlusProfile');
|
||||
$scope.isLoading = false;
|
||||
}
|
||||
};// End goToUserProfile.
|
||||
|
||||
//getUserProfile is for get user information form localStorage by calling localStorage.get service.
|
||||
$scope.getUserProfile = function () {
|
||||
$scope.userInfo = localStorage.get("GooglePlus");
|
||||
if ($scope.userInfo != null) {
|
||||
$scope.isLogin = true;
|
||||
}
|
||||
;
|
||||
return $scope.userInfo;
|
||||
};// End getUserProfile.
|
||||
|
||||
// login for google login
|
||||
$scope.login = function () {
|
||||
if ($scope.isLoading == false) {
|
||||
$scope.isLoading = true;
|
||||
|
||||
// Calling $cordovaOauth.google for login google.
|
||||
// Format:
|
||||
// $cordovaOauth.google(CLIENT_ID,[GOOGLE_PERMISION])
|
||||
// For CLIENT_ID is window.globalVariable.oAuth.googlePlus from www/js/app.js at globalVariable session.
|
||||
$cordovaOauth.google(window.globalVariable.oAuth.googlePlus
|
||||
, ["https://www.googleapis.com/auth/urlshortener",
|
||||
"https://www.googleapis.com/auth/userinfo.email"]).then(function (result) {
|
||||
//After call cordovaOauth.google it will return access_token for you to calling google API.
|
||||
|
||||
$scope.accessToken = result.access_token;
|
||||
// Calling http service for getting user profile from google.
|
||||
// By send parameter access_token, format.
|
||||
$http.get("https://www.googleapis.com/oauth2/v1/userinfo", {
|
||||
params: {
|
||||
access_token: result.access_token,
|
||||
format: "json"
|
||||
}
|
||||
}).then(function (result) {
|
||||
// Success retrieve data by calling http service.
|
||||
// Store user profile information from google API to userInfo variable.
|
||||
$scope.userInfo = {
|
||||
name: result.data.name,
|
||||
email: result.data.email,
|
||||
link: result.data.link,
|
||||
pictureProfileUrl: result.data.picture,
|
||||
gender: result.data.gender,
|
||||
id: result.data.id,
|
||||
access_token: $scope.accessToken
|
||||
};
|
||||
// Store user profile information to localStorage service.
|
||||
localStorage.set("GooglePlus", $scope.userInfo);
|
||||
// Navigate to google plus profile page.
|
||||
$scope.navigateTo("app.googlePlusProfile");
|
||||
});
|
||||
|
||||
}
|
||||
, function (error) {
|
||||
// Error retrieve data.
|
||||
console.log(error);
|
||||
});
|
||||
$scope.isLoading = false;
|
||||
}
|
||||
};// End login.
|
||||
|
||||
$scope.initialForm();
|
||||
});// End of google plus login controller.
|
||||
|
||||
// Controller of google plus profile Page.
|
||||
appControllers.controller('googlePlusProfileCtrl', function ($mdDialog, $scope, $state, $stateParams, $cordovaOauth, $ionicHistory, $http, localStorage, $timeout) {
|
||||
|
||||
// This function is the first activity in the controller.
|
||||
// It will initial all variable data and let the function works when page load.
|
||||
$scope.initialForm = function () {
|
||||
|
||||
// $scope.userInfo is the variable for store user profile information
|
||||
// It get data from localStorage service.
|
||||
$scope.userInfo = localStorage.get("GooglePlus");
|
||||
|
||||
// $scope.loading is the variable for loading progress.
|
||||
$scope.loading = true;
|
||||
|
||||
// The function for show/hide loading progress.
|
||||
$timeout(function () {
|
||||
$scope.loading = false;
|
||||
}, 2000);
|
||||
};// End initialForm.
|
||||
|
||||
// navigateTo is for navigate to other page
|
||||
// by using targetPage to be the destination page
|
||||
// Parameter :
|
||||
// targetPage = destination page.
|
||||
$scope.navigateTo = function (targetPage) {
|
||||
$state.go(targetPage);
|
||||
};// End navigateTo
|
||||
|
||||
// logOut is for log out it will clear google plus data in localStorage service.
|
||||
$scope.logOut = function ($event) {
|
||||
//mdDialog.show use for show alert box for confirm to log out.
|
||||
$mdDialog.show({
|
||||
controller: 'DialogController',
|
||||
templateUrl: 'confirm-dialog.html',
|
||||
targetEvent: $event,
|
||||
locals: {
|
||||
displayOption: {
|
||||
title: "Confirm to Logout",
|
||||
content: "Do you want to logout Google Plus?",
|
||||
ok: "Confirm",
|
||||
cancel: "Close"
|
||||
}
|
||||
}
|
||||
}).then(function () {
|
||||
// For confirm button to log out.
|
||||
// Clear google plus data in localStorage service.
|
||||
localStorage.set("GooglePlus", null);
|
||||
// Navigate to log in page.
|
||||
$scope.userinfoData = localStorage.get("GooglePlus");
|
||||
if ($scope.userinfoData == null) {
|
||||
$state.go('app.googlePlusLogin');
|
||||
}
|
||||
|
||||
}, function () {
|
||||
// For cancel button to log out.
|
||||
});
|
||||
};// End logOut
|
||||
|
||||
$scope.initialForm();
|
||||
|
||||
});// End of google plus profile controller.
|
||||
|
||||
// Controller of google plus feed Page.
|
||||
appControllers.controller('googlePlusFeedCtrl', function ($scope, $state, $ionicHistory, $stateParams, $cordovaOauth, $http, localStorage) {
|
||||
|
||||
// This function is the first activity in the controller.
|
||||
// It will initial all variable data and let the function works when page load.
|
||||
$scope.initialForm = function () {
|
||||
|
||||
// $scope.paging is the variable that store page index of feed data.
|
||||
$scope.paging = {
|
||||
next: "",
|
||||
shouldLoadData: false
|
||||
};
|
||||
// $scope.userInfo is the variable for store user profile information
|
||||
// It get data from localStorage service.
|
||||
$scope.userInfo = localStorage.get("GooglePlus");
|
||||
|
||||
// $scope.loading is the variable for loading progress.
|
||||
$scope.isLoading = false;
|
||||
|
||||
// $scope.feedList is the variable that store feed data.
|
||||
$scope.feedList = [];
|
||||
}// End initialForm.
|
||||
|
||||
// getFeedData is for get feed by calling to google API.
|
||||
// Parameter :
|
||||
// IsInit(bool) = for check that page are loading more data or refresh data.
|
||||
$scope.getFeedData = function (IsInit) {
|
||||
// Call http service with this api to get google plus feed data.
|
||||
// By send parameter access_token that get from google plus user profile from localStorage.
|
||||
$http.get("https://www.googleapis.com/plus/v1/people/me/activities/public", {
|
||||
params: {
|
||||
access_token: $scope.userInfo.access_token
|
||||
}
|
||||
})
|
||||
.then(function (result) {
|
||||
// Success retrieve data by calling http service.
|
||||
|
||||
// Store feed data to $scope.feedList variable to show in feed.
|
||||
$scope.feedList = result.data.items;
|
||||
|
||||
// If it don't have data. Loading progress will stop and appear empty feed.
|
||||
if ($scope.feedList == []) {
|
||||
$scope.paging.shouldLoadData = true;
|
||||
};
|
||||
|
||||
// Checking for next page data
|
||||
if (result.data.nextPageToken == null) {
|
||||
$scope.paging.shouldLoadData = true;
|
||||
}
|
||||
else {
|
||||
$scope.paging.next = result.data.nextPageToken;
|
||||
}// End checking for next page data.
|
||||
|
||||
// To stop loading progress.
|
||||
if (IsInit == true) {
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
} else {
|
||||
$scope.$broadcast('scroll.refreshComplete');
|
||||
}
|
||||
$scope.isLoading = false;
|
||||
}
|
||||
, function (error) {
|
||||
// Error retrieve data it will log out.
|
||||
if (error.code = 403) {
|
||||
$scope.logout();
|
||||
}
|
||||
$scope.paging.shouldLoadData = true;
|
||||
});
|
||||
|
||||
}; // End getFeedData.
|
||||
|
||||
// logout for log out.
|
||||
$scope.logout = function () {
|
||||
// Clear google plus data in localStorage service.
|
||||
localStorage.set("GooglePlus", null);
|
||||
// Navigate to log in page.
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableBack: true
|
||||
});
|
||||
$scope.userinfoData = localStorage.get("GooglePlus");
|
||||
if ($scope.userinfoData == null) {
|
||||
$state.go('app.googlePlusLogin');
|
||||
};
|
||||
};// End logout.
|
||||
|
||||
// getNextFeedData for get next page of feed data.
|
||||
$scope.getNextFeedData = function () {
|
||||
$scope.isLoading = true;
|
||||
// Call http service with google API and send parameter pageToken that get from the previous feed.
|
||||
$http.get("https://www.googleapis.com/plus/v1/people/me/activities/public", {
|
||||
params: {
|
||||
access_token: $scope.userInfo.access_token,
|
||||
pageToken: $scope.paging.next
|
||||
}
|
||||
}).then(function (result) {
|
||||
// Success retrieve data by calling http service.
|
||||
|
||||
// storing feed data to $scope.feedList.
|
||||
for (var feedItem = 0; feedItem < result.data.items.length; feedItem++) {
|
||||
$scope.feedList.push(result.data.items[feedItem]);
|
||||
}
|
||||
// Checking for next page data.
|
||||
if (result.data.nextPageToken == null) {
|
||||
|
||||
$scope.paging.shouldLoadData = true;
|
||||
}
|
||||
else {
|
||||
|
||||
$scope.paging.next = result.data.nextPageToken;
|
||||
}// End checking for next page data.
|
||||
|
||||
// To stop loading progress.
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
$scope.isLoading = false;
|
||||
});
|
||||
};// End getNextFeedData.
|
||||
|
||||
// doRefresh is for refresh feed.
|
||||
$scope.doRefresh = function () {
|
||||
$scope.paging.shouldLoadData = false;
|
||||
$scope.getFeedData(false);
|
||||
};// End doRefresh.
|
||||
|
||||
// loadMore is for loading more feed.
|
||||
$scope.loadMore = function () {
|
||||
if ($scope.isLoading == false) {
|
||||
$scope.isLoading = true;
|
||||
if ($scope.paging.next == "") {
|
||||
$scope.getFeedData(true);
|
||||
} else {
|
||||
$scope.getNextFeedData();
|
||||
}
|
||||
}
|
||||
};// End loadMore.
|
||||
$scope.initialForm();
|
||||
|
||||
});// End of google plus feed controller.
|
||||
Reference in New Issue
Block a user