Skip to content

Commit aad08fe

Browse files
committed
code_style: rewrite editing repository node in welcome page
Signed-off-by: leo <longshuang@msn.cn>
1 parent 13207e8 commit aad08fe

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

src/ViewModels/EditRepositoryNode.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,42 @@ namespace SourceGit.ViewModels
66
{
77
public class EditRepositoryNode : Popup
88
{
9-
public string Id
9+
public string Target
1010
{
11-
get => _id;
12-
set => SetProperty(ref _id, value);
11+
get;
1312
}
1413

15-
[Required(ErrorMessage = "Name is required!")]
16-
public string Name
14+
public bool IsRepository
1715
{
18-
get => _name;
19-
set => SetProperty(ref _name, value, true);
16+
get;
2017
}
2118

2219
public List<int> Bookmarks
2320
{
2421
get;
2522
}
2623

27-
public int Bookmark
24+
[Required(ErrorMessage = "Name is required!")]
25+
public string Name
2826
{
29-
get => _bookmark;
30-
set => SetProperty(ref _bookmark, value);
27+
get => _name;
28+
set => SetProperty(ref _name, value, true);
3129
}
3230

33-
public bool IsRepository
31+
public int Bookmark
3432
{
35-
get => _isRepository;
36-
set => SetProperty(ref _isRepository, value);
33+
get => _bookmark;
34+
set => SetProperty(ref _bookmark, value);
3735
}
3836

3937
public EditRepositoryNode(RepositoryNode node)
4038
{
4139
_node = node;
42-
_id = node.Id;
4340
_name = node.Name;
44-
_isRepository = node.IsRepository;
4541
_bookmark = node.Bookmark;
4642

43+
Target = node.IsRepository ? node.Id : node.Name;
44+
IsRepository = node.IsRepository;
4745
Bookmarks = new List<int>();
4846
for (var i = 0; i < Models.Bookmarks.Brushes.Length; i++)
4947
Bookmarks.Add(i);
@@ -65,9 +63,7 @@ public override Task<bool> Sure()
6563
}
6664

6765
private RepositoryNode _node = null;
68-
private string _id = null;
6966
private string _name = null;
70-
private bool _isRepository = false;
7167
private int _bookmark = 0;
7268
}
7369
}

src/Views/EditRepositoryNode.axaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,26 @@
2424
IsVisible="{Binding IsRepository}"/>
2525
</StackPanel>
2626

27-
<Grid Height="28" Margin="8,16,0,0" ColumnDefinitions="120,*" >
28-
<TextBlock Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,8,0" Text="{DynamicResource Text.EditRepositoryNode.Target}"/>
29-
<TextBlock Grid.Column="1" VerticalAlignment="Center" Text="{Binding Name, Mode=OneTime}" IsVisible="{Binding !IsRepository}"/>
30-
<TextBlock Grid.Column="1" VerticalAlignment="Center" Text="{Binding Id, Mode=TwoWay}" IsVisible="{Binding IsRepository}"/>
27+
<Grid Height="28" Margin="8,16,0,0" ColumnDefinitions="120,Auto,*" >
28+
<TextBlock Grid.Column="0"
29+
HorizontalAlignment="Right" VerticalAlignment="Center"
30+
Margin="0,0,8,0"
31+
Text="{DynamicResource Text.EditRepositoryNode.Target}"/>
32+
33+
<Path Grid.Column="1"
34+
Width="12" Height="12"
35+
Margin="0,1,0,0"
36+
Data="{StaticResource Icons.Folder.Open}"
37+
IsVisible="{Binding !IsRepository, Mode=OneWay}"/>
38+
<Path Grid.Column="1"
39+
Width="12" Height="12"
40+
Data="{StaticResource Icons.Repositories}"
41+
IsVisible="{Binding IsRepository, Mode=OneWay}"/>
42+
43+
<TextBlock Grid.Column="2"
44+
Margin="6,0,0,0"
45+
VerticalAlignment="Center"
46+
Text="{Binding Target, Mode=OneWay}"/>
3147
</Grid>
3248
<Grid Height="28" Margin="8,4,0,0" ColumnDefinitions="120,*">
3349
<TextBlock Grid.Column="0" HorizontalAlignment="Right" Margin="0,0,8,0" Text="{DynamicResource Text.EditRepositoryNode.Name}"/>

0 commit comments

Comments
 (0)