Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Commit

Permalink
refac
Browse files Browse the repository at this point in the history
  • Loading branch information
Flayms committed Jan 5, 2021
1 parent c3b9f2f commit 78f4d3c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions MublogMobile/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ResourceDictionary>
<Color x:Key="Primary">#fff1e8</Color>
<Color x:Key="Back">#7884ab</Color>
<Color x:Key="Back2">#fff1e8</Color>
<Color x:Key="Text">Black</Color>
<Color x:Key="Link">#3898ff</Color>

Expand Down
9 changes: 5 additions & 4 deletions MublogMobile/Models/User.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MublogMobile.Services;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System;
using System.Linq;

namespace MublogMobile.Models
Expand All @@ -13,7 +13,8 @@ public class User
public string ImageUrl { get; } //todo: cache profile image


private const string _EMPTY_URL = "00000000-0000-0000-0000-000000000000";
private const string _EMPTY_GUID = "00000000-0000-0000-0000-000000000000";
private static readonly Uri _MEDIA_URI = new Uri(MainLogic.API_URI,"/api/v1/media/");

private static readonly string[] _placeHolderUrls = new[]
{
Expand Down Expand Up @@ -58,9 +59,9 @@ public static User GetOrCreateUser(JToken jUser)
var displayName = (string)jUser["displayName"];
var profileUrl = (string)jUser["profileImageUrl"];

user = profileUrl == _EMPTY_URL
user = profileUrl == _EMPTY_GUID
? new User(alias, displayName)
: new User(alias, displayName, profileUrl);
: new User(alias, displayName, _MEDIA_URI + profileUrl);

existingUsers.Add(user);
}
Expand Down
11 changes: 5 additions & 6 deletions MublogMobile/Services/MainLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,28 @@ public static MainLogic Instance
public bool IsInitialized;
private static MainLogic _instance;
public HttpClient Client { get; } = new HttpClient();
private static readonly Uri _API_URI = new Uri("https://mublog.xyz/");

public static readonly Uri API_URI = new Uri("https://mublog.xyz/");

public User CurrentUser { get; private set; }
private List<Post> _posts;
public List<User> AllUsers { get; } = new List<User>();

private MainLogic()
{
this.Client.BaseAddress = _API_URI;
this.Client.BaseAddress = API_URI;
}

public async void Init()
{
this._posts = (await Post.LoadAll()).OrderBy(p => p.DateCreated).ToList();
this._posts = (await Post.LoadAll());
this.CurrentUser = this.AllUsers.FirstOrDefault();
this.LoginAsync();
//this.LoginAsync();

this.IsInitialized = true;
}

public async void LoginAsync()
{
{
var jsonLogin = this.CurrentUser.GetJsonLogin("password");
var content = new StringContent(jsonLogin, Encoding.UTF8, "application/json");
var response = await this.Client.PostAsync("/api/v1/accounts/login", content);
Expand Down
4 changes: 2 additions & 2 deletions MublogMobile/Views/PostView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
HorizontalOptions="Center"
Padding="0"
IsClippedToBounds="True">
<Image Source="{Binding ImageSource}" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="40" HeightRequest="40">
<Image Source="{Binding ImageSource}" BackgroundColor="{StaticResource Back2}" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="40" HeightRequest="40">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="_OnUserTapped"/>
</Image.GestureRecognizers>
</Image>
</Frame>

</StackLayout>
<Frame OutlineColor="Black" BackgroundColor="#fff1e8" CornerRadius="7" Padding="0" Margin="5, 0, 5, 5" Grid.Column="1">
<Frame OutlineColor="Black" BackgroundColor="{StaticResource Back2}" CornerRadius="7" Padding="0" Margin="5, 0, 5, 5" Grid.Column="1">
<StackLayout Spacing="0">
<Grid Margin="5">
<Grid.ColumnDefinitions>
Expand Down
4 changes: 2 additions & 2 deletions MublogMobile/Views/ProfilePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ContentPage.Content>
<StackLayout>

<Frame BackgroundColor="#fff1e8"
<Frame BackgroundColor="{StaticResource Back2}"
Padding="0">
<Grid Padding="10">
<Grid.ColumnDefinitions>
Expand All @@ -28,7 +28,7 @@
Grid.Column="0" Grid.Row="0" Grid.RowSpan="2"
IsClippedToBounds="True">

<Image Source="{Binding ImageSource}" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="65" HeightRequest="65">
<Image Source="{Binding ImageSource}" BackgroundColor="{StaticResource Back2}" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="65" HeightRequest="65">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="_OnImageNameTapped"/>
</Image.GestureRecognizers>
Expand Down

0 comments on commit 78f4d3c

Please sign in to comment.