Skip to content

Commit

Permalink
Personalizable options (#36)
Browse files Browse the repository at this point in the history
* Implementing personalizable options

- Personalizing dot color per day
- Personalizing properties related with the font of the arrows
- Adding personalizable command to execute when a day is tapped

* Adding custom dots

- Adding class DayEventCollection to allow changin the dot color per day
- Updating the example using the new wrapper DayEventCollection

* Fixing property

- Fixing duplicated property

* Fixing dot

- Removing outline color of the dot

* Fixing header appearance

- Fixing distribution of the spaces
- Fixing out of bounds in the name of the month when the display has configured the bigger display size and the bigger font size

* Updating example

- Adding support of fontawesome to the example
- Adding example of the new properties to change the appearance

* Updating documentation

- Updating documentation with new options to customize the calendar and new screenshots

* Format code

- Removing format code done over existing code

* Version code

- Changing the version code

* Separeate Simple and Advance Calender Sample
- Removed Arrows properties it should be setted on Header and Footer custom implementation
-

* added support for colors on event indicator

* revert dayview sizes, code cleanup

* added evnet click command

* fix ios images, update sample image, update readme
Co-authored-by: Diego Martinez <[email protected]>
Co-authored-by: MintDevTeam <[email protected]>
  • Loading branch information
anTONIos authored Mar 24, 2020
1 parent 2c3a53b commit 2810593
Show file tree
Hide file tree
Showing 78 changed files with 1,330 additions and 388 deletions.
72 changes: 56 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,35 @@
[![Chat](https://img.shields.io/badge/Telegram-chat-blue.svg)](https://t.me/XamarinPluginCalendar)
[![License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/LICENSE)

| Android | iPhone |
| ------- | ------ |
| ![Android Calendar Screenshot](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/art/Android.jpg) | ![iPhone Calendar Screenshot](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/art/iPhone_XS.png) |

Simple cross platform plugin for Calendar control featuring:
- Displaying events by binding EventCollection
- Localization support with System.Globalization.CultureInfo
- Customizeable colors, day view sizes/label styles, custom Header/Footer template support
- Customizable colors, day view sizes/label styles, custom Header/Footer template support
- UI reactive to EventCollection, Culture and other changes

We are open to any suggestions and feedback, and we got our community telegram group [here](https://t.me/XamarinPluginCalendar) :)
If you are coming back take a look on the [Changelog here](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/CHANGELOG.md).

## Simple Implementation
| Android | iPhone |
| ------- | ------ |
| ![Android Calendar Screenshot](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/art/android-simple.png) | ![iPhone Calendar Screenshot](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/art/iphone-simple.png) |

## Advanced implementation
| Android | iPhone |
| ------- | ------ |
| ![Android Custom Calendar Screenshot](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/art/android-advanced.png) | ![iPhone Custom Calendar Screenshot](https://github.com/lilcodelab/Xamarin.Plugin.Calendar/blob/master/art/iphone-advanced.png) |


### Setup
* Available on NuGet
* https://www.nuget.org/packages/Xamarin.Plugin.Calendar/

#### Supported versions
| Platform | Version |
| -------- | ------- |
| Xamarin.Forms | 4.4+ |
| Xamarin.Android | ? |
| -------- | -------
| Xamarin.Forms | 3.3+ |
| Xamarin.Android | 8.1+ |
| Xamarin.iOS | ? |

### Usage
Expand All @@ -48,10 +55,10 @@ Basic control usage:
```

Bindable properties:
* `Culture` (CultureInfo)
* `Month` (int)
* `Year` (int)
* `Events` (EventCollection - from package)
* `Culture` CultureInfo
* `Month` int
* `Year` int
* `Events` EventCollection (from package)
* Custom colors, fonts, sizes ...

#### Binding events:
Expand Down Expand Up @@ -84,7 +91,7 @@ using Xamarin.Plugin.Calendar.Models;

Add property for Events:
```csharp
public EventCollection Events { get; private set; }
public EventCollection Events { get; set; }
```

Initialize Events with your data:
Expand All @@ -106,14 +113,42 @@ Events = new EventCollection
[DateTime.Now.AddDays(-3)] = new List<EventModel>
{
new EventModel { Name = "Cool event5", Description = "This is Cool event5's description!" }
},
// custom date
[new DateTime(2020, 3, 16))] = new List<EventModel>
{
new EventModel { Name = "Cool event6", Description = "This is Cool event6's description!" }
}
},
};
```

Initialize Events with your data and a different dot color per day:
```csharp
Events = new EventCollection
{
//2 days ago
[DateTime.Now.AddDays(-2)] = new DayEventCollection<EventModel>{ Color.Purple, Color.Purple)
{
new EventModel { Name = "Cool event1", Description = "This is Cool event1's description!" },
new EventModel { Name = "Cool event2", Description = "This is Cool event2's description!" }
},
// 5 days ago
[DateTime.Now.AddDays(-5)] = new DayEventCollection<EventModel>(Color.Blue, Color.Blue)
{
new EventModel { Name = "Cool event3", Description = "This is Cool event3's description!" },
new EventModel { Name = "Cool event4", Description = "This is Cool event4's description!" }
},
};
//4 days ago
Events.Add(DateTime.Now.AddDays(-4), new DayEventCollection<EventModel>(GenerateEvents(10, "Cool")) { EventIndicatorColor = Color.Green, EventIndicatorSelectedColor = Color.Green });
```

Where `EventModel` is just an example, it can be replaced by any data model you desire.

`EventsCollection` is just a wrapper over `Dictionary<DateTime, ICollection>` exposing custom `Add` method and `this[DateTime]` indexer which internally extracts the `.Date` component of `DateTime` values and uses it as a key in this dictionary.

`DayEventCollection` is just a wrapper over `List<T>` exposing custom properties `EventIndicatorColor` and `EventIndicatorSelectedColor` for assigning a custom color to the dot.

#### Available color customization
Sample properties:
```xml
Expand All @@ -123,7 +158,6 @@ SelectedDateColor="Red"
SelectedDayBackgroundColor="DarkCyan"
EventIndicatorColor="Red"
EventIndicatorSelectedColor="White"
ArrowsColor="DarkCyan"
DaysTitleColor="Orange"
SelectedDayTextColor="Cyan"
DeselectedDayTextColor="Blue"
Expand All @@ -132,11 +166,17 @@ TodayOutlineColor="Blue"
TodayFillColor="Silver"
```

#### Available other customization properties
Sample properties:
```xml
AnimateCalendar="False"<!--Enable/Disable animation when calendar is loaded or refreshed-->
```

##### TODO
* ~~screenshot of changed colors~~
* comment public properties and methods
* Add default public template for Header with "← Month, Year" format
* Update Readme and create wiki pages
* Create advanced sample (more real-world) in the root of the repo with referenced nuget package
* ~~Create advanced sample (more real-world) in the root of the repo with referenced nuget package~~

Josip Ćaleta @lilcodelab
Binary file removed art/Android.jpg
Binary file not shown.
Binary file added art/android-advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/android-simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed art/iPhone_XS.png
Binary file not shown.
Binary file added art/iphone-advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/iphone-simple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,3h-1L19,1h-2v2L7,3L7,1L5,1v2L4,3c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,5c0,-1.1 -0.9,-2 -2,-2zM20,21L4,21L4,8h16v13z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9,11L7,11v2h2v-2zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM19,4h-1L18,2h-2v2L8,4L8,2L6,2v2L5,4c-1.11,0 -1.99,0.9 -1.99,2L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20L5,9h14v11z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M17,12h-5v5h5v-5zM16,1v2L8,3L8,1L6,1v2L5,3c-1.11,0 -1.99,0.9 -1.99,2L3,19c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2h-1L18,1h-2zM19,19L5,19L5,8h14v11z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.4.0.991640" />
<PackageReference Include="Xamarin.Forms" Version="4.5.0.356" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.3" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.3" />
Expand All @@ -67,6 +67,8 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\font-awesome-5-free-regular.otf" />
<AndroidAsset Include="Assets\font-awesome-5-free-solid.otf" />
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
<None Include="Properties\AndroidManifest.xml" />
Expand All @@ -89,26 +91,72 @@
<AndroidResource Include="Resources\mipmap-xxxhdpi\icon.png" />
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher_foreground.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\drawable-hdpi\" />
<Folder Include="Resources\drawable-xhdpi\" />
<Folder Include="Resources\drawable-xxhdpi\" />
<Folder Include="Resources\drawable-xxxhdpi\" />
<Folder Include="Resources\drawable\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

<ItemGroup>
<ProjectReference Include="..\..\Calendar.Plugin\CalendarPlugin.csproj">
<Project>{81e938f4-a11c-4726-a13f-0d7ecc84ca66}</Project>
<Project>{81e938f4-a11c-4726-a13f-0d7ecc84ca66}</Project>
<Name>CalendarPlugin</Name>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SampleApp\SampleApp.csproj">
<Project>{E4FB5119-AAD4-43E4-8741-1759FAF4083B}</Project>
<Name>SampleApp</Name>
</ProjectReference>
</ItemGroup>
</Project>
<ItemGroup>
<AndroidResource Include="Resources\drawable\baseline_calendar_today_24.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\baseline_date_range_24.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\baseline_event_24.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-hdpi\baseline_calendar_today_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-hdpi\baseline_date_range_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-hdpi\baseline_event_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-mdpi\baseline_calendar_today_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-mdpi\baseline_date_range_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-mdpi\baseline_event_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\baseline_calendar_today_black_36.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\baseline_date_range_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xhdpi\baseline_event_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxxhdpi\baseline_calendar_today_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxxhdpi\baseline_date_range_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxxhdpi\baseline_event_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\baseline_calendar_today_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\baseline_date_range_black_24.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable-xxhdpi\baseline_event_black_24.png" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"images": [
{
"appearances": [],
"scale": "1x",
"idiom": "universal",
"filename": "baseline_calendar_today_black_24pt_1x.png"
},
{
"appearances": [],
"scale": "2x",
"idiom": "universal",
"filename": "baseline_calendar_today_black_24pt_2x.png"
},
{
"appearances": [],
"scale": "3x",
"idiom": "universal",
"filename": "baseline_calendar_today_black_24pt_3x.png"
}
],
"properties": {},
"info": {
"version": 1,
"author": "xcode",
"template-rendering-intent": "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"images": [
{
"appearances": [],
"scale": "1x",
"idiom": "universal",
"filename": "baseline_date_range_black_24pt_1x.png"
},
{
"appearances": [],
"scale": "2x",
"idiom": "universal",
"filename": "baseline_date_range_black_24pt_2x.png"
},
{
"appearances": [],
"scale": "3x",
"idiom": "universal",
"filename": "baseline_date_range_black_24pt_3x.png"
}
],
"properties": {},
"info": {
"version": 1,
"author": "xcode",
"template-rendering-intent": "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"images": [
{
"appearances": [],
"scale": "1x",
"idiom": "universal",
"filename": "baseline_event_black_24pt_1x.png"
},
{
"appearances": [],
"scale": "2x",
"idiom": "universal",
"filename": "baseline_event_black_24pt_2x.png"
},
{
"appearances": [],
"scale": "3x",
"idiom": "universal",
"filename": "baseline_event_black_24pt_3x.png"
}
],
"properties": {},
"info": {
"version": 1,
"author": "xcode",
"template-rendering-intent": "template"
}
}
5 changes: 5 additions & 0 deletions src/Calendar.Plugin.Sample/SampleApp.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
<string>SampleApp</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>UIAppFonts</key>
<array>
<string>font-awesome-5-free-regular.otf</string>
<string>font-awesome-5-free-solid.otf</string>
</array>
</dict>
</plist>
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 2810593

Please sign in to comment.