Skip to content

Commit

Permalink
Merge pull request #189 from OudomMunint/dev
Browse files Browse the repository at this point in the history
Dev => main
  • Loading branch information
OudomMunint authored May 24, 2024
2 parents d3e8266 + 5b2f676 commit 7fed60f
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 101 deletions.
Binary file modified Resources/Images/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 0 additions & 20 deletions Views/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,9 @@ public Settings()

protected override void OnAppearing()
{
#if IOS
UpdateTitle();
#endif
base.OnAppearing();
}

private void UpdateTitle()
{
TodoListPage todolistapge = new TodoListPage();
ListView listView = todolistapge.todolistlist;

int totalItems = listView.ItemsSource?.Cast<object>().Count() ?? 0;
string task = "Task";

if (totalItems != 1)
{
task += "s";
}
Title = $"🏠 {totalItems} Opened";
}

// Dark Mode
private void DarkMode(object sender, EventArgs e)
{
Expand Down Expand Up @@ -111,8 +93,6 @@ private static async Task MakeDummyData()

await database.SaveItemAsync(item);
}

// await UpdateListView();
}

private async void GenerateData_Button_Pressed(System.Object sender, System.EventArgs e)
Expand Down
49 changes: 6 additions & 43 deletions Views/TodoListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
x:Name="todoListPage"
Title="Home"
Shell.PresentationMode="ModalAnimated">
<!--<ContentPage.ToolbarItems>
<ToolbarItem Clicked="MarkSelectedItemsComplete" IconImageSource="donetoolbar.png"/>
<ToolbarItem Clicked="DeleteSelectedItems" IconImageSource="trash.png"/>
<ToolbarItem Clicked="OnItemAdded" IconImageSource="icon.png"/>
<ToolbarItem Clicked="OpenMenu" IconImageSource="menu.png"/>
</ContentPage.ToolbarItems>-->

<NavigationPage.TitleView>
<Grid>
Expand Down Expand Up @@ -42,7 +36,7 @@

<!--<views:HeaderGrid x:Name="HeaderGrid" Grid.Row="0"/>-->

<Frame x:Name="SearchContainer" HeightRequest="40" Grid.Row="1" Margin="5" Padding="5" Style="{StaticResource CustomFrame}" >
<Frame x:Name="SearchContainer" HeightRequest="40" BackgroundColor="{OnPlatform iOS=Transparent}" Grid.Row="1" Margin="5" Padding="5" Style="{StaticResource CustomFrame}" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand All @@ -68,7 +62,7 @@
</VerticalStackLayout>

<ListView x:Name="listView" Grid.Row="2" Margin="10" ItemSelected="OnListItemSelected" RowHeight="115" SeparatorVisibility="None"
CachingStrategy="RecycleElement" BackgroundColor="{AppThemeBinding Light={DynamicResource White}, Dark={DynamicResource Black}}" IsPullToRefreshEnabled="True" Refreshing="RefreshView_Refreshing">
CachingStrategy="RecycleElement" IsPullToRefreshEnabled="True" Refreshing="RefreshView_Refreshing">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
Expand Down Expand Up @@ -143,43 +137,11 @@
</HorizontalStackLayout>
</Frame>

<!--<Frame Grid.Row="1" Grid.Column="2" WidthRequest="70" Padding="0,0,0,0" Margin="0,10,40,0" HeightRequest="25" BorderColor="Transparent">
<Frame.Triggers>
<DataTrigger TargetType="Frame" Binding="{Binding Priority}" Value="High">
<Setter Property="BackgroundColor" Value="{DynamicResource HighPriorityColor}" />
</DataTrigger>
<DataTrigger TargetType="Frame" Binding="{Binding Priority}" Value="Medium">
<Setter Property="BackgroundColor" Value="{DynamicResource MediumPriorityColor}" />
</DataTrigger>
<DataTrigger TargetType="Frame" Binding="{Binding Priority}" Value="Low">
<Setter Property="BackgroundColor" Value="{DynamicResource LowPriorityColor}" />
</DataTrigger>
<DataTrigger TargetType="Frame" Binding="{Binding Priority}" Value="Critical">
<Setter Property="BackgroundColor" Value="{DynamicResource CriticalPriorityColor}" />
</DataTrigger>
<DataTrigger TargetType="Frame" Binding="{Binding Priority}" Value="">
<Setter Property="BackgroundColor" Value="Transparent" />
</DataTrigger>
</Frame.Triggers>
<Label HorizontalOptions="Center" VerticalOptions="Center" TextColor="Black" FontFamily="Inter-Regular" Text="{Binding Priority}">
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding Priority}" Value="Critical">
<Setter Property="TextColor" Value="White" />
</DataTrigger>
</Label.Triggers>
</Label>
</Frame>-->

<Frame Grid.Row="2" Grid.Column="3" HeightRequest="25" Margin="0,10,0,0" Padding="5" BorderColor="Gray">
<Frame Grid.Row="2" Grid.Column="{OnPlatform Android=2, iOS=3}" HorizontalOptions="{OnPlatform Android=Start}" HeightRequest="25" Margin="0,10,0,0" Padding="{OnPlatform Android=3, iOS=5}" BorderColor="Gray">
<Frame.Triggers>
<DataTrigger TargetType="Frame" Binding="{Binding Done}" Value="True">
<Setter Property="WidthRequest" Value="80" />
<Setter Property="Margin" Value="0,10,15,0"/>
<!--<Setter Property="Margin" Value="0,10,15,0"/>-->
</DataTrigger>

<DataTrigger TargetType="Frame" Binding="{Binding Done}" Value="False">
Expand All @@ -197,7 +159,8 @@
</DataTrigger>
</Image.Triggers>
</Image>
<Label VerticalTextAlignment="Center" FontAutoScalingEnabled="False" FontFamily="Inter-Bold" TextColor="{AppThemeBinding Dark=White, Light=Black}">
<Label VerticalTextAlignment="Center" FontAutoScalingEnabled="False" FontFamily="Inter-Bold" TextColor="{AppThemeBinding Dark=White, Light=Black}"
Margin="{OnPlatform Android='0,0,0,0'}">
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding Done}" Value="True">
<Setter Property="Text" Value="Done" />
Expand Down
12 changes: 9 additions & 3 deletions Views/TodoListPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,27 @@ namespace ToDoListApp.Views
public partial class TodoListPage : ContentPage
{
// dark mode property
private AppTheme darkmode = AppTheme.Dark;
private readonly AppTheme darkmode = AppTheme.Dark;

[Obsolete]
public TodoListPage()
{
InitializeComponent();
todolistlist = listView;

Application.Current.RequestedThemeChanged += (s, a) =>
Application.Current.RequestedThemeChanged += (s, a) =>
{
if (Application.Current.RequestedTheme == darkmode)
{
// set searchbar background color to DarkGH from Colors.xaml
SearchContainer.BackgroundColor = (Color)Application.Current.Resources["DarkGH"];
SearchContainer.BackgroundColor = Color.FromHex("#161B22");
listView.BackgroundColor = Colors.Black;
}

else
{
listView.BackgroundColor = Colors.White;
}
};
}

Expand Down
38 changes: 11 additions & 27 deletions Views/TodoitemPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

<Label x:Name="itemTitle" Grid.Column="0" TextColor="White" VerticalTextAlignment="Center" FontSize="18" FontFamily="Inter-Regular"/>

<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" Spacing="10">
<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" Spacing="5">
<ImageButton HorizontalOptions="Start" Source="saveitem.png" Clicked="OnSaveClicked" HeightRequest="25"/>
<ImageButton HorizontalOptions="End" Source="menu.png" Clicked="OpenMenu2" HeightRequest="35"/>
<ImageButton HorizontalOptions="End" WidthRequest="25" Source="attachment.png" Clicked="AttMenu_Clicked" HeightRequest="35"/>
<ImageButton HorizontalOptions="End" Source="menu.png" Clicked="OpenMenu" HeightRequest="35"/>
</HorizontalStackLayout>

</Grid>
Expand Down Expand Up @@ -69,7 +70,7 @@
</HorizontalStackLayout>

<Frame Style="{DynamicResource ToDoItemFrame}" Padding="10" Margin="0,10,0,0" CornerRadius="10">
<Picker x:Name="PriorityPicker" Title="Tap to set priority">
<Picker x:Name="PriorityPicker">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Low</x:String>
Expand Down Expand Up @@ -108,36 +109,19 @@

<!--<BoxView HeightRequest="1" Color="Gray" Margin="0,-10,0,0"/>-->

<Frame HorizontalOptions="FillAndExpand" Style="{StaticResource ToDoItemFrame}">
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Label Margin="10,0,10,0"
<Frame HorizontalOptions="FillAndExpand" Style="{StaticResource ToDoItemFrame}">
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Label Margin="10,0,10,0"
HorizontalOptions="Start"
VerticalOptions="Center"
FontFamily="Inter-Bold"
Text="Mark as Done" />

<Switch HorizontalOptions="EndAndExpand" IsToggled="{Binding Done}" OnColor="Green" ThumbColor="Gray" />
<Switch HorizontalOptions="EndAndExpand" IsToggled="{Binding Done}" OnColor="Green" ThumbColor="Gray" />

</StackLayout>
</Frame>

<!--<Grid ColumnSpacing="20" RowSpacing="10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" BackgroundColor="BlueViolet" Clicked="OnSaveClicked" Text="Save" FontFamily="Inter-Regular"/>
<Button Grid.Row="0" Grid.Column="1" BackgroundColor="Grey" Clicked="OnCancelClicked" Text="Cancel" FontFamily="Inter-Regular"/>
<Button Grid.Row="1" Grid.ColumnSpan="2" BackgroundColor="Red" Clicked="OnDeleteClicked" Text="Delete" FontFamily="Inter-Regular"/>
</Grid>-->
</StackLayout>
</StackLayout>
</Frame>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
54 changes: 46 additions & 8 deletions Views/TodoitemPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,37 @@ protected override void OnAppearing()
base.OnAppearing();
UpdateToolbarTitle();
GetAttachmentCount();
SetSelectedPriorityLabel();
}

private void SetSelectedPriorityLabel()
{
var todoItem = (Todoitem)BindingContext;

if (todoItem.Priority == "Low")
{
PriorityPicker.Title = "Low";
PriorityPicker.SelectedIndex = 0;
}
else if (todoItem.Priority == "Medium")
{
PriorityPicker.Title = "Medium";
PriorityPicker.SelectedIndex = 1;
}
else if (todoItem.Priority == "High")
{
PriorityPicker.Title = "High";
PriorityPicker.SelectedIndex = 2;
}
else if (todoItem.Priority == "Critical")
{
PriorityPicker.Title = "Critical";
PriorityPicker.SelectedIndex = 3;
}
else
{
PriorityPicker.Title = "Select Priority";
}
}

private void GetAttachmentCount()
Expand Down Expand Up @@ -220,27 +251,34 @@ public async void UploadPhoto(object sender, EventArgs e)
}
}

public async void OpenMenu2(object sender, EventArgs e)
public async void OpenMenu(object sender, EventArgs e)
{
string addatachment = "Take Photo";
string uploadatachment = "Upload Attachment";
string delete = "Delete Item";
string clear = "Clear Form";

var action = await Application.Current.MainPage.DisplayActionSheet(null, "Cancel", null, new[] { addatachment, uploadatachment, delete, clear });
var action = await Application.Current.MainPage.DisplayActionSheet(null, "Cancel", null, new[] { delete, clear });

if (action != null && action.Equals(delete))
{
OnDeleteClicked(sender, e);
}
else if (action != null && action.Equals(addatachment))
{
TakePhoto(sender, e);
}
else if (action != null && action.Equals(clear))
{
OnClearClicked(sender, e);
}
}

public async void AttMenu_Clicked(object sender, EventArgs e)
{
string addatachment = "Take Photo";
string uploadatachment = "Upload Attachment";

var action = await Application.Current.MainPage.DisplayActionSheet(null, "Cancel", null, new[] { addatachment, uploadatachment });

if (action != null && action.Equals(addatachment))
{
TakePhoto(sender, e);
}
else if (action != null && action.Equals(uploadatachment))
{
UploadPhoto(sender, e);
Expand Down

0 comments on commit 7fed60f

Please sign in to comment.