Skip to content

Commit 6b1ae63

Browse files
committed
Done with add page
1 parent e538743 commit 6b1ae63

9 files changed

Lines changed: 55 additions & 44 deletions

File tree

CutCode/App.xaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
<FontFamily x:Key="poppins_semibold">pack://CutCode:,,,Resources/Fonts/#Poppins SemiBold</FontFamily>
1313
<FontFamily x:Key="poppins_regular">pack://CutCode:,,,Resources/Fonts/#Poppins Regular</FontFamily>
14-
<FontFamily x:Key="roboto_light">pack://CutCode:,,,Resources/Fonts/#Roboto Light</FontFamily>
15-
<FontFamily x:Key="roboto_regular">pack://CutCode:,,,Resources/Fonts/#Roboto Regular</FontFamily>
16-
<FontFamily x:Key="cascadiaMono">pack://CutCode:,,,Resources/Fonts/#Fira Code</FontFamily>
14+
<FontFamily x:Key="firacode">pack://CutCode:,,,Resources/Fonts/#Fira Code</FontFamily>
1715

1816
<!--Scrollbar Thumbs-->
1917
<Style x:Key="ScrollThumbs" TargetType="{x:Type Thumb}">

CutCode/CutCode.csproj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<None Remove="Resources\Fonts\CascadiaMono.ttf" />
11-
<None Remove="Resources\Fonts\FiraCode-Light.ttf" />
1210
<None Remove="Resources\Fonts\FiraCode-Regular.ttf" />
1311
<None Remove="Resources\Fonts\Poppins-Regular.ttf" />
1412
<None Remove="Resources\Fonts\Poppins-SemiBold.ttf" />
15-
<None Remove="Resources\Fonts\Roboto-Bold.ttf" />
16-
<None Remove="Resources\Fonts\Roboto-Light.ttf" />
17-
<None Remove="Resources\Fonts\Roboto-Regular.ttf" />
1813
<None Remove="Resources\Images\Icons\add_black.png" />
1914
<None Remove="Resources\Images\Icons\add_white.png" />
2015
<None Remove="Resources\Images\Icons\exit_black.png" />
@@ -45,14 +40,9 @@
4540
</ItemGroup>
4641

4742
<ItemGroup>
48-
<Resource Include="Resources\Fonts\CascadiaMono.ttf" />
49-
<Resource Include="Resources\Fonts\FiraCode-Light.ttf" />
5043
<Resource Include="Resources\Fonts\FiraCode-Regular.ttf" />
5144
<Resource Include="Resources\Fonts\Poppins-Regular.ttf" />
5245
<Resource Include="Resources\Fonts\Poppins-SemiBold.ttf" />
53-
<Resource Include="Resources\Fonts\Roboto-Bold.ttf" />
54-
<Resource Include="Resources\Fonts\Roboto-Light.ttf" />
55-
<Resource Include="Resources\Fonts\Roboto-Regular.ttf" />
5646
<Resource Include="Resources\Images\Icons\add_black.png" />
5747
<Resource Include="Resources\Images\Icons\add_white.png" />
5848
<Resource Include="Resources\Images\Icons\exit_black.png" />
-610 KB
Binary file not shown.
-161 KB
Binary file not shown.
-166 KB
Binary file not shown.
-166 KB
Binary file not shown.
-167 KB
Binary file not shown.

CutCode/ViewModels/AddViewModel.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public AddViewModel(IThemeService _themeService)
2222
"Any languages", "Python", "C++", "C#", "CSS", "Dart", "Golang", "Html", "Java",
2323
"Javascript", "Kotlin", "Php", "C", "Ruby", "Rust","Sql", "Swift"
2424
};
25-
25+
leftText = "";
2626
SetAppearance();
2727
}
2828
private void ThemeChanged(Object sender, EventArgs e)
@@ -89,9 +89,27 @@ public string code
8989
set => SetAndNotify(ref _code, value);
9090
}
9191

92-
public void DoneClicked()
92+
private string _leftText;
93+
public string leftText
9394
{
95+
get => _leftText;
96+
set => SetAndNotify(ref _leftText, value);
97+
}
9498

99+
public void DoneClicked()
100+
{
101+
if (string.IsNullOrEmpty(title))
102+
{
103+
leftText = "Title should not be emtpy";
104+
}
105+
else if (string.IsNullOrEmpty(code))
106+
{
107+
leftText = "Please add a code";
108+
}
109+
else
110+
{
111+
// done lets add the code ...
112+
}
95113
}
96114
}
97115
}

CutCode/Views/AddView.xaml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,20 @@
2727
</Grid.Resources>
2828

2929
<Grid.RowDefinitions>
30-
<RowDefinition Height="Auto"/>
3130
<RowDefinition Height="Auto"/>
3231
<RowDefinition Height="Auto"/>
3332
<RowDefinition Height="*"/>
3433
<RowDefinition Height="Auto"/>
3534
</Grid.RowDefinitions>
3635

37-
38-
<Label Grid.Row="0" Content="Add code" FontFamily="{StaticResource poppins_semibold}" Foreground="{Binding textBoxForeground}" FontSize="20" Margin="10,5,0,0"/>
39-
40-
<Grid Grid.Row="1">
36+
<Grid Grid.Row="0">
4137
<Grid.ColumnDefinitions>
4238
<ColumnDefinition Width="Auto"/>
4339
<ColumnDefinition Width="Auto"/>
4440
</Grid.ColumnDefinitions>
4541

4642
<Grid Grid.Column="0">
47-
<Border BorderThickness="0" Background="{Binding textBoxBackground}" Margin="10,0,5,5" CornerRadius="8" Height="38">
43+
<Border BorderThickness="0" Background="{Binding textBoxBackground}" Margin="10,18,5,5" CornerRadius="8" Height="38">
4844
<Grid>
4945
<TextBox x:Name="titleEntry" MaxLength="40" Margin="5,0,25,0" Width="400" VerticalContentAlignment="Center"
5046
Background="{Binding textBoxBackground}" Foreground="{Binding textBoxForeground}"
@@ -85,9 +81,9 @@
8581
</Grid>
8682
</Grid>
8783

88-
<Border Grid.Row="2" BorderThickness="0" Background="{Binding textBoxBackground}" Margin="10,15,5,5" CornerRadius="8" Height="68" HorizontalAlignment="Left" Width="600">
84+
<Border Grid.Row="1" BorderThickness="0" Background="{Binding textBoxBackground}" Margin="10,15,5,5" CornerRadius="8" Height="68" HorizontalAlignment="Left" Width="600">
8985
<Grid>
90-
<TextBox x:Name="descEntry" Margin="5,7,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" MaxLength="120"
86+
<TextBox x:Name="descEntry" Margin="5,7,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MaxLength="120"
9187
Background="{Binding textBoxBackground}" Foreground="{Binding textBoxForeground}" TextWrapping="Wrap"
9288
Text="{Binding desc}" FontFamily="{StaticResource poppins_regular}" FontSize="15" BorderThickness="0"/>
9389

@@ -107,33 +103,42 @@
107103
</Grid>
108104
</Border>
109105

110-
<Border Grid.Row="3" BorderThickness="0" Background="{Binding textBoxBackground}" Margin="10,15,12,5" CornerRadius="8"
106+
<Border Grid.Row="2" BorderThickness="0" Background="{Binding textBoxBackground}" Margin="10,15,12,5" CornerRadius="8"
111107
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
112-
<Grid>
113-
<local:CustomTextEditor x:Name="codeEditor" Margin="5,9,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" MaxLength="2000"
108+
<ScrollViewer Style="{StaticResource ScrollViewerStyle}">
109+
<Grid>
110+
<local:CustomTextEditor x:Name="codeEditor" ScrollViewer.HorizontalScrollBarVisibility="Auto" Margin="5,9,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
114111
Background="{Binding textBoxBackground}" Foreground="{Binding textBoxForeground}" TextWrapping="Wrap" AcceptsReturn="True"
115-
Text="{Binding code}" FontFamily="{StaticResource cascadiaMono}" AcceptsTab="True" FontSize="14" BorderThickness="0"/>
112+
Text="{Binding code}" FontFamily="{StaticResource firacode}" AcceptsTab="True" FontSize="14" BorderThickness="0"/>
116113

117-
<TextBlock Text="Start by typing your code here ..." FontSize="15" FontFamily="{StaticResource poppins_regular}"
114+
<TextBlock Text="Start by typing your code here ..." FontSize="15" FontFamily="{StaticResource poppins_regular}"
118115
IsHitTestVisible="False" Foreground="#929292" Margin="10,7,0,0">
119-
<TextBlock.Style>
120-
<Style TargetType="{x:Type TextBlock}">
121-
<Setter Property="Visibility" Value="Collapsed"/>
122-
<Style.Triggers>
123-
<DataTrigger Binding="{Binding Text, ElementName=codeEditor}" Value="">
124-
<Setter Property="Visibility" Value="Visible"/>
125-
</DataTrigger>
126-
</Style.Triggers>
127-
</Style>
128-
</TextBlock.Style>
129-
</TextBlock>
130-
</Grid>
116+
<TextBlock.Style>
117+
<Style TargetType="{x:Type TextBlock}">
118+
<Setter Property="Visibility" Value="Collapsed"/>
119+
<Style.Triggers>
120+
<DataTrigger Binding="{Binding Text, ElementName=codeEditor}" Value="">
121+
<Setter Property="Visibility" Value="Visible"/>
122+
</DataTrigger>
123+
</Style.Triggers>
124+
</Style>
125+
</TextBlock.Style>
126+
</TextBlock>
127+
</Grid>
128+
</ScrollViewer>
131129
</Border>
132130

133-
<Grid Grid.Row="4">
134-
<Border Background="{Binding textBoxBackground}" BorderThickness="0" Width="90" CornerRadius="7" Height="32" HorizontalAlignment="Center" Margin="5,0,30,7">
135-
<Button Content="Done" Background="Transparent" BorderThickness="0" FontFamily="{StaticResource poppins_regular}" Foreground="{Binding textBoxForeground}"
136-
FontSize="18" BorderBrush="{Binding richtextBoxBackground}">
131+
<Grid Grid.Row="3">
132+
<Grid.ColumnDefinitions>
133+
<ColumnDefinition Width="*"/>
134+
<ColumnDefinition Width="*"/>
135+
</Grid.ColumnDefinitions>
136+
137+
<Label Grid.Column="0" Content="{Binding leftText}" HorizontalAlignment="Right" Foreground="Red" FontSize="13" FontFamily="{StaticResource poppins_regular}"/>
138+
139+
<Border Grid.Column="1" Background="{Binding textBoxBackground}" BorderThickness="0" Width="120" CornerRadius="7" Height="32" HorizontalAlignment="Center" Margin="5,0,30,7">
140+
<Button Content="Add code" Background="Transparent" BorderThickness="0" FontFamily="{StaticResource poppins_regular}" Foreground="{Binding textBoxForeground}"
141+
FontSize="18" BorderBrush="{Binding richtextBoxBackground}" Command="{s:Action DoneClicked}">
137142
<Button.Style>
138143
<Style TargetType="Button">
139144
<Setter Property="Background" Value="Transparent"/>

0 commit comments

Comments
 (0)