Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Main things work
Browse files Browse the repository at this point in the history
  • Loading branch information
yazdipour committed Nov 25, 2018
1 parent 3c2a2b3 commit eb63a03
Show file tree
Hide file tree
Showing 30 changed files with 279 additions and 540 deletions.
4 changes: 2 additions & 2 deletions source/GithubX.Shared/Models/Category.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public class Category
{
public int Id { get; set; }
public int OrderId;
public int Id { get; set; } = -1;
public int OrderId { get; set; }
public string Color { get; set; } = "#ffffffff";
public string Title { get; set; } = "new_category";
public GradientColor Background { get; set; } = new GradientColor("#5B247A", "#1BCEDF");
Expand Down
62 changes: 0 additions & 62 deletions source/GithubX.Shared/Models/Repo.cs

This file was deleted.

31 changes: 0 additions & 31 deletions source/GithubX.Shared/Models/RepoContent.cs

This file was deleted.

17 changes: 0 additions & 17 deletions source/GithubX.Shared/Models/User.cs

This file was deleted.

26 changes: 19 additions & 7 deletions source/GithubX.Shared/Services/Github/RepositoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public async Task<Readme> GetRepositoryReadme(long repoId)
=> await client.Repository.Content.GetReadme(repoId);

public async Task<IReadOnlyList<RepositoryContent>> GetRepositoryContent(long repoId)
=> (await client.Repository.Content.GetAllContents(repoId));
=> await client.Repository.Content.GetAllContents(repoId);

public async Task<IReadOnlyList<RepositoryContent>> GetRepositoryContent(long repoId, string path)
=> (await client.Repository.Content.GetAllContents(repoId, path));
=> await client.Repository.Content.GetAllContents(repoId, path);

private async Task<string> GetMarkDownReadyAsync(string url, bool fromCache = true)
{
Expand All @@ -51,17 +51,29 @@ private async Task<string> GetMarkDownReadyAsync(string url, bool fromCache = tr
}
public async Task<string> GetMarkDownReadyAsync(RepositoryContent content)
{
var type = content.Name.Substring(content.Name.LastIndexOf("."));
var type = content.Name.Substring(content.Name.LastIndexOf(".") + 1);
if (type.Equals("png", StringComparison.OrdinalIgnoreCase)
|| type.Equals("jpg", StringComparison.OrdinalIgnoreCase)
|| type.Equals("jpeg", StringComparison.OrdinalIgnoreCase)
|| type.Equals("bmp", StringComparison.OrdinalIgnoreCase)
|| type.Equals("tiff", StringComparison.OrdinalIgnoreCase))
return $"![]({content.Url})";
var oldSha = await BlobCache.LocalMachine.GetObject<string>("_" + content.Url) ?? "";
return $"![]({content.DownloadUrl})";
else if (type.Equals("mp4", StringComparison.OrdinalIgnoreCase)
|| type.Equals("mkv", StringComparison.OrdinalIgnoreCase)
|| type.Equals("flv", StringComparison.OrdinalIgnoreCase)
|| type.Equals("flv", StringComparison.OrdinalIgnoreCase)
|| type.Equals("mp3", StringComparison.OrdinalIgnoreCase)){
return $"Can't Open {type} file.\nDownload Link → {content.DownloadUrl}";
}
var oldSha = "";
try
{
oldSha = await BlobCache.LocalMachine.GetObject<string>("_" + content.Url) ?? "";
}
catch { }
var result = await GetMarkDownReadyAsync(content.DownloadUrl, content.Sha.Equals(oldSha));
await BlobCache.LocalMachine.InsertObject("_" + content.Url, content.Sha);
var result = await GetMarkDownReadyAsync(content.Url, content.Sha.Equals(oldSha));
return type.Equals("md", StringComparison.OrdinalIgnoreCase) ? result : $"``` {result} ```";
return type.Equals("md", StringComparison.OrdinalIgnoreCase) ? result : $"```{type} {result} ```";
}
#endregion

Expand Down
19 changes: 6 additions & 13 deletions source/GithubX.Shared/Services/Github/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,20 @@ public async Task<IReadOnlyList<User>> GetAllFollowers(ApiOptions options, strin
: await client.User.Followers.GetAll(user, options);
#endregion

#region Gist
public async Task<IReadOnlyList<Gist>> GetUserGists(string user = null)
=> (user == null)
=> user == null
? await client.Gist.GetAll()
: await client.Gist.GetAllForUser(user);
#endregion

#region Repos
public async Task<IReadOnlyList<Repository>> GetUserRepositories(ApiOptions options)
=> (await client.Repository.GetAllForCurrent(options));

public async Task<IReadOnlyList<Repository>> GetRepositoriesForUser(string user, ApiOptions options)
=> (await client.Repository.GetAllForUser(user, options));
#endregion
public async Task<IReadOnlyList<Repository>> GetUserRepositories(ApiOptions options, string user = null)
=> user == null
? (await client.Repository.GetAllForCurrent(options))
: (await client.Repository.GetAllForUser(user, options));

#region Star
public async Task<IReadOnlyList<Repository>> GetStarredRepositories(ApiOptions options, string user = null)
=> (user == null)
=> user == null
? (await client.Activity.Starring.GetAllForCurrent(options))
: (await client.Activity.Starring.GetAllForUser(user, options));
#endregion

public async Task<IReadOnlyList<Activity>> GetUserActivity(ApiOptions options, string user)
=> await client.Activity.Events.GetAllUserReceived(user, options);
Expand Down
7 changes: 4 additions & 3 deletions source/GithubX.UWP/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ResourceDictionary Source="Theme\ColorPalette.xaml" />
<!--<ResourceDictionary Source="CompactSize.xaml"/>-->
</ResourceDictionary.MergedDictionaries>
<x:Int32 x:Key="DefaultWidth">240</x:Int32>
<x:Double x:Key="DefaultWidth">260</x:Double>
<x:Int32 x:Key="DefaultCorner">6</x:Int32>
<Color x:Key="AcrylicBrushTintColor1">#eee</Color>
<Color x:Key="AcrylicBrushFallbackColor1">#eee</Color>
Expand Down Expand Up @@ -43,6 +43,7 @@
<Setter Property="IsItemClickEnabled" Value="True" />
<Setter Property="IsSwipeEnabled" Value="True" />
<Setter Property="SelectionMode" Value="None" />
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Disabled" />
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="HeaderTemplate">
Expand All @@ -68,15 +69,15 @@
<Style x:Key="CardGrid" TargetType="Grid">
<Setter Property="Background" Value="{ThemeResource CardColor}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="CornerRadius" Value="6" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="Width" Value="{ThemeResource DefaultWidth}" />
</Style>
<Style x:Key="CardStack" TargetType="StackPanel">
<Setter Property="Background" Value="{ThemeResource CardColor}" />
<Setter Property="Margin" Value="0,4,4,4" />
<Setter Property="Padding" Value="8,4" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="CornerRadius" Value="6" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="Width" Value="{ThemeResource DefaultWidth}" />
</Style>
<Style x:Key="ShadowCard" TargetType="toolkit:DropShadowPanel">
Expand Down
19 changes: 14 additions & 5 deletions source/GithubX.UWP/Converters/StringConcatConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ internal class StringConcatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var res = language.Equals("End")
? (string)parameter + (string)value
: (string)value + (string)parameter;
if (targetType.Name == "Uri") return new Uri(res);
return res;
try
{
var res = language.Equals("End")
? parameter.ToString() + value.ToString()
: value.ToString() + parameter.ToString();
if (targetType.Name == "Uri") return new Uri(res);
return res;
}
catch (Exception ex)
{

Shared.Services.Logger.E(ex);
return null;
}
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
Expand Down
18 changes: 2 additions & 16 deletions source/GithubX.UWP/GithubX.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@
<Compile Include="Views\Controls\ActivityItem.xaml.cs">
<DependentUpon>ActivityItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\CategoryItem.xaml.cs">
<DependentUpon>CategoryItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\GistItem.xaml.cs">
<DependentUpon>GistItem.xaml</DependentUpon>
</Compile>
Expand All @@ -131,7 +128,7 @@
<Compile Include="Views\Controls\UserItem.xaml.cs">
<DependentUpon>UserItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\AddCategoryDialog.xaml.cs">
<Compile Include="Views\Dialogs\AddCategoryDialog.xaml.cs">
<DependentUpon>AddCategoryDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Dialogs\NotificationDialog.xaml.cs">
Expand All @@ -149,9 +146,6 @@
<Compile Include="Views\Controls\NotificationItem.xaml.cs">
<DependentUpon>NotificationItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Dialogs\CategoryDialog.xaml.cs">
<DependentUpon>CategoryDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Views\FollowPage.xaml.cs">
<DependentUpon>FollowPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -258,10 +252,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\CategoryItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Controls\GistItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand All @@ -274,7 +264,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\AddCategoryDialog.xaml">
<Page Include="Views\Dialogs\AddCategoryDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand All @@ -298,10 +288,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Dialogs\CategoryDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\FollowPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
3 changes: 1 addition & 2 deletions source/GithubX.UWP/Views/ActivitiesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
Margin="8,42,0,0"
ItemClick="GridView_ItemClick"
ItemsSource="{x:Bind activityRepositories}"
ScrollViewer.HorizontalScrollMode="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollMode="Disabled"
Style="{StaticResource MainGridView}">
<GridView.ItemTemplate>
<DataTemplate x:DataType="octo:Activity">
Expand Down
43 changes: 42 additions & 1 deletion source/GithubX.UWP/Views/CategoriesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:local="using:GithubX.UWP.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:GithubX.Shared.Models"
xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls"
mc:Ignorable="d">
<Grid>
<TextBlock
Expand All @@ -21,7 +22,47 @@
Style="{ThemeResource MainGridView}">
<GridView.ItemTemplate>
<DataTemplate x:DataType="model:Category">
<ctrl:CategoryItem />
<toolkit:DropShadowPanel Style="{StaticResource ShadowCard}">
<Grid
Width="{StaticResource DefaultWidth}"
RequestedTheme="Dark"
Style="{StaticResource CardGrid}">
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="{x:Bind Background.Color1}" />
<GradientStop Offset="1" Color="{x:Bind Background.Color2}" />
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Margin="4,8"
VerticalAlignment="Center"
FontFamily="/Assets/Files/devicon.ttf#devicon"
FontSize="36"
Text="{x:Bind Icon}" />
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
FontFamily="Candara"
FontSize="22"
FontWeight="SemiBold"
MaxLines="1"
Text="{x:Bind Title}" />
<Button
Grid.Column="2"
Background="Transparent"
Click="Add_Click"
Content=""
DataContext="{x:Bind}"
FontFamily="Segoe MDL2 Assets"
Style="{StaticResource CircleButtonStyle}" />
</Grid>
</toolkit:DropShadowPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
Expand Down
Loading

0 comments on commit eb63a03

Please sign in to comment.