Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show rooms as list #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
Expand Down Expand Up @@ -58,7 +57,7 @@
<PackageReference Include="Xam.Plugins.Forms.ImageCircle">
<Version>3.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="3.6.0.344457" />
<PackageReference Include="Xamarin.Forms" Version="4.2.0.848062" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.1" />
Expand Down Expand Up @@ -108,7 +107,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DayVsNight\DayVsNight.csproj">
<Project>{2281C826-8A05-42C6-8329-6DF1CA9F6B99}</Project>
<Project>{160D0FC7-B7C6-4352-807F-6EC525641ACA}</Project>
<Name>DayVsNight</Name>
</ProjectReference>
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/DayVsNight/DayVsNight/DayVsNight.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Android.Widget;
using Android.OS;
using ImageCircle.Forms.Plugin.Droid;
using Xamarin.Forms;

namespace DayVsNight.Droid
{
Expand All @@ -20,6 +21,7 @@ protected override void OnCreate(Bundle savedInstanceState)

base.OnCreate(savedInstanceState);

Forms.SetFlags("CollectionView_Experimental");
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
ImageCircleRenderer.Init();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.DayVsNight">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<application android:label="DayVsNight.Android"></application>
</manifest>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27" />
<application android:label="DayVsNight.Android"></application>
</manifest>
9,227 changes: 4,631 additions & 4,596 deletions src/DayVsNight/DayVsNight/DayVsNight.Android/Resources/Resource.designer.cs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/DayVsNight/DayVsNight/DayVsNight.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Foundation;
using ImageCircle.Forms.Plugin.iOS;
using UIKit;
using Xamarin.Forms;

namespace DayVsNight.iOS
{
Expand All @@ -23,6 +24,7 @@ public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsAppli
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
Forms.SetFlags("CollectionView_Experimental");
global::Xamarin.Forms.Forms.Init();
ImageCircleRenderer.Init();
LoadApplication(new App());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<PackageReference Include="Xam.Plugins.Forms.ImageCircle">
<Version>3.0.0.5</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="3.6.0.344457" />
<PackageReference Include="Xamarin.Forms" Version="4.2.0.848062" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
<PackageReference Include="Xamarin.Forms.PancakeView">
<Version>1.0.21</Version>
Expand All @@ -143,7 +143,7 @@
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\DayVsNight\DayVsNight.csproj">
<Project>{2281C826-8A05-42C6-8329-6DF1CA9F6B99}</Project>
<Project>{160D0FC7-B7C6-4352-807F-6EC525641ACA}</Project>
<Name>DayVsNight</Name>
</ProjectReference>
</ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/DayVsNight/DayVsNight/DayVsNight/DayVsNight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<PackageReference Include="SkiaSharp.Svg" Version="1.60.0" />
<PackageReference Include="SkiaSharp.Views.Forms" Version="1.68.0" />
<PackageReference Include="Xam.Plugins.Forms.ImageCircle" Version="3.0.0.5" />
<PackageReference Include="Xamarin.Forms" Version="3.6.0.344457" />
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
<PackageReference Include="Xamarin.Forms" Version="4.2.0.848062" />
<PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
<PackageReference Include="Xamarin.Forms.PancakeView" Version="1.0.21" />
</ItemGroup>

Expand Down Expand Up @@ -62,4 +62,7 @@
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>
</Project>
100 changes: 35 additions & 65 deletions src/DayVsNight/DayVsNight/DayVsNight/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
Source="{DynamicResource MountainImage}"
VerticalOptions="End" />

<StackLayout Padding="20,30,20,0">
<StackLayout Padding="20,30,20,0"
Grid.Row="0">

<!-- Header Section -->
<!--Header Section-->
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
Expand Down Expand Up @@ -64,7 +65,7 @@
</circleimge:CircleImage>
</Grid>

<!-- Top events alert -->
<!--Top events alert-->
<Frame
Margin="0,20,0,0"
Padding="10"
Expand Down Expand Up @@ -100,7 +101,7 @@

<Label Style="{StaticResource SubHeader}" Text="Temperature" />

<!-- Temp Guage -->
<!--Temp Guage-->
<Grid HeightRequest="170">

<local:GaugeControl />
Expand All @@ -120,15 +121,15 @@
Text="◦◦◦"
TextColor="White" />
</Grid>
<!-- Security -->

<!--Security-->
<Label
Margin="0"
Style="{StaticResource SubHeader}"
Text="Security" />

<ScrollView HorizontalScrollBarVisibility="Never" Orientation="Horizontal">
<StackLayout Orientation="Horizontal">
<!-- room -->
<pancake:PancakeView CornerRadius="10">
<Grid
BackgroundColor="Red"
Expand Down Expand Up @@ -183,69 +184,38 @@
</Frame>
</Grid>
</pancake:PancakeView>


</StackLayout>
</ScrollView>

</StackLayout>

<!-- bottom tab layout -->
<ScrollView
Grid.Row="1"
Margin="20,20,20,40"
HorizontalScrollBarVisibility="Never"
Orientation="Horizontal">
<StackLayout Orientation="Horizontal" Spacing="20">
<StackLayout Orientation="Vertical">
<BoxView
BackgroundColor="White"
HeightRequest="2"
WidthRequest="130" />
<Label Style="{StaticResource TabHeader}" Text="Kitchen" />
<Label
Margin="0,-5,0,0"
Style="{StaticResource SubText}"
Text="5 Active Devices"
TextColor="White" />
</StackLayout>


<StackLayout Orientation="Vertical">
<BoxView
BackgroundColor="{StaticResource TabSubTextColor}"
HeightRequest="1"
WidthRequest="100" />
<Label
Style="{StaticResource TabHeader}"
Text="Study"
TextColor="{StaticResource TabSubTextColor}" />
<Label
Margin="0,-5,0,0"
Style="{StaticResource TabSubText}"
Text="5 Active Devices"
TextColor="{StaticResource TabSubTextColor}" />
</StackLayout>

<StackLayout Orientation="Vertical">
<BoxView
BackgroundColor="{StaticResource TabSubTextColor}"
HeightRequest="1"
WidthRequest="100" />
<Label
Style="{StaticResource TabHeader}"
Text="Bed Room"
TextColor="{StaticResource TabSubTextColor}" />
<Label
Margin="0,-5,0,0"
Style="{StaticResource TabSubText}"
Text="5 Active Devices"
TextColor="{StaticResource TabSubTextColor}" />
</StackLayout>
</StackLayout>

</ScrollView>

<CollectionView ItemsSource="{Binding Rooms}"
Margin="20,20,20,20"
HeightRequest="70"
HorizontalScrollBarVisibility="Never"
Grid.Row="1">
<CollectionView.ItemsLayout>
<ListItemsLayout ItemSpacing="20">
<x:Arguments>
<ItemsLayoutOrientation>Horizontal</ItemsLayoutOrientation>
</x:Arguments>
</ListItemsLayout>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Vertical">
<BoxView
BackgroundColor="White"
HeightRequest="2"
WidthRequest="130" />
<Label Style="{StaticResource TabHeader}" Text="{Binding Name}" />
<Label
Margin="0,-5,0,0"
Style="{StaticResource SubText}"
Text="{Binding DevicesActive}" TextColor="White" />
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>

</ContentPage>
30 changes: 29 additions & 1 deletion src/DayVsNight/DayVsNight/DayVsNight/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using DayVsNight.Themes;
using DayVsNight.Models;
using DayVsNight.Themes;
using SkiaSharp;
using SkiaSharp.Views.Forms;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using Xamarin.Forms;

Expand All @@ -12,9 +15,34 @@ namespace DayVsNight
[DesignTimeVisible(true)]
public partial class MainPage : ContentPage
{
public ObservableCollection<Room> Rooms { get; set; } = new ObservableCollection<Room>();

public MainPage()
{
InitializeComponent();

Room kitchen = new Room() { Name = "Kitchen" };
kitchen.Devices.Add(new Models.Device() { Name = "Ceiling light", IsActive = true });
kitchen.Devices.Add(new Models.Device() { Name = "Oven", IsActive = true });
kitchen.Devices.Add(new Models.Device() { Name = "Toaster", IsActive = true });
kitchen.Devices.Add(new Models.Device() { Name = "Dishwasher", IsActive = false });

Rooms.Add(kitchen);

Room study = new Room() { Name = "Study" };
study.Devices.Add(new Models.Device() { Name = "Ceiling light", IsActive = true });
study.Devices.Add(new Models.Device() { Name = "Bureau light", IsActive = false });

Rooms.Add(study);

Room bedRoom = new Room() { Name = "Bedroom" };
bedRoom.Devices.Add(new Models.Device() { Name = "Ceiling light", IsActive = false });
bedRoom.Devices.Add(new Models.Device() { Name = "Nightdesk light", IsActive = true });
bedRoom.Devices.Add(new Models.Device() { Name = "Airco", IsActive = true });

Rooms.Add(bedRoom);

BindingContext = this;
}

protected override void OnAppearing()
Expand Down
10 changes: 10 additions & 0 deletions src/DayVsNight/DayVsNight/DayVsNight/Models/Device.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace DayVsNight.Models
{
public class Device
{
public string Name { get; set; }
public bool IsActive { get; set; }
}
}
14 changes: 14 additions & 0 deletions src/DayVsNight/DayVsNight/DayVsNight/Models/Room.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace DayVsNight.Models
{
public class Room
{
public string Name { get; set; }
public List<Device> Devices { get; set; } = new List<Device>();

public string DevicesActive => $"{Devices.Where(i => i.IsActive).Count()} active devices";
}
}