-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added marked date class * Added multiple_marked_dates class * Renamed market_date to marked date * Added comments * Remover border color from marked date Co-authored-by: takunda <madechangu.takunda2gmail.com>
- Loading branch information
Showing
3 changed files
with
150 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MarkedDate implements MarkedDateInterface { | ||
final Color color; | ||
final int? id; | ||
final TextStyle? textStyle; | ||
final DateTime date; | ||
|
||
MarkedDate({ | ||
required this.color, | ||
this.id, | ||
this.textStyle, | ||
required this.date, | ||
}); | ||
|
||
@override | ||
bool operator ==(dynamic other) { | ||
return this.date == other.date && | ||
this.color == other.color && | ||
this.textStyle == other.textStyle && | ||
this.id == other.id; | ||
} | ||
|
||
@override | ||
DateTime getDate() => this.date; | ||
|
||
@override | ||
int? getId() => this.id; | ||
|
||
@override | ||
Color getColor() => this.color; | ||
|
||
|
||
@override | ||
TextStyle? getTextStyle() => this.textStyle; | ||
} | ||
|
||
|
||
|
||
|
||
abstract class MarkedDateInterface { | ||
DateTime getDate(); | ||
Color getColor(); | ||
int? getId(); | ||
TextStyle? getTextStyle(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
import 'marked_date.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class MultipleMarkedDates{ | ||
List<MarkedDate> markedDates; | ||
|
||
MultipleMarkedDates({required this.markedDates}); | ||
|
||
void add(MarkedDate markedDate){ | ||
markedDates.add(markedDate); | ||
} | ||
|
||
void addAll(List<MarkedDate> markedDates){ | ||
this.markedDates.addAll(markedDates); | ||
} | ||
|
||
bool remove(MarkedDate markedDate){ | ||
return markedDates.remove(markedDate); | ||
} | ||
|
||
void clear() { | ||
markedDates.clear(); | ||
} | ||
|
||
bool isMarked(DateTime date){ | ||
final results = markedDates.firstWhere((element) => element.date == date, orElse: () => MarkedDate(color: Colors.black, date: DateTime(0))); | ||
return results.date.year == date.year; | ||
} | ||
|
||
Color getColor(DateTime date){ | ||
final results = markedDates.firstWhere((element) => element.date == date, orElse: () => MarkedDate(color: Colors.black, date: DateTime(0))); | ||
return results.color; | ||
} | ||
|
||
DateTime getDate(DateTime date){ | ||
final results = markedDates.firstWhere((element) => element.date == date, orElse: () => MarkedDate(color: Colors.black, date: DateTime(0))); | ||
return results.date; | ||
} | ||
|
||
TextStyle? getTextStyle(DateTime date){ | ||
final results = markedDates.firstWhere((element) => element.date == date, orElse: () => MarkedDate(color: Colors.black, date: DateTime(0))); | ||
return results.textStyle; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters