Skip to content

Commit

Permalink
Merge branch 'main' into push-notification-update
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothvino42 authored Dec 6, 2023
2 parents ef30076 + d72e67e commit dbbb290
Show file tree
Hide file tree
Showing 11 changed files with 334 additions and 122 deletions.
45 changes: 28 additions & 17 deletions assets/schema/ensemble_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@
},
"cssStyles": {
"type": "array",
"oneOf": [
"items": [
{
"type": "object",
"properties": {
Expand Down Expand Up @@ -1558,6 +1558,10 @@
"type": "boolean",
"description": "enable the toggling between plain and obscure text."
},
"toolbarDone": {
"type": "boolean",
"description": "enable the toolbar with done button in the TextInput. (defaults to False)"
},
"enableClearText": {
"type": "boolean",
"description": "It enables the default suffix clear icon button for the text input field to clear the values. Default (false)"
Expand Down Expand Up @@ -5883,13 +5887,13 @@
}
},
{
"title": "Youtube",
"title": "YouTube",
"required": [
"Youtube"
"YouTube"
],
"properties": {
"Youtube" : {
"$ref" : "#/$defs/Youtube-payload"
"YouTube" : {
"$ref" : "#/$defs/YouTube-payload"
}
}
},
Expand Down Expand Up @@ -6542,60 +6546,67 @@
}
}
},
"Youtube-payload":{
"YouTube-payload":{
"type" : "object",
"properties" : {
"id" : {
"type" : "string",
"description": "The unique identifier for this widget"
},
"styles": {
"$ref": "#/$defs/boxStyles"
},
"url" : {
"type": "string",
"description": "The URL source to the youtube video"
"description": "The URL source to the youTube video"
},
"aspectRatio" : {
"type": "double",
"type": "number",
"description" : "Video aspect ratio"
},
"autoplay": {
"type" : "bool",
"type" : "boolean",
"description" : "Automatically start the video when player is loaded. (default False)"
},
"videoList" : {
"type" : "array",
"type" : "object",
"description" : "List of videos to be played within a single player."
},
"startSeconds": {
"type" : "double",
"type" : "number",
"description" : "specifies the time from which the first video in the list(or single video) should start playing"
},
"endSeconds": {
"type": "double",
"type": "number",
"description": "Ends the video after the certain number of seconds (works with Single video)"
},
"showAnnotations" : {
"type" : "bool",
"type" : "boolean",
"description" : "Showing the annotations of the video"
},
"playbackRate" : {
"type": "double",
"type": "number",
"description": "For changing the speed at which the video is displayed"
},
"showControls": {
"type" : "bool",
"type" : "boolean",
"description" : "For showing the controls on the video within the player(Like in youtube)"
},
"showFullScreenButton": {
"type" : "bool",
"type" : "boolean",
"description" : "To show the fullscreen button of the video"
},
"enableCaptions" : {
"type": "bool",
"type": "boolean",
"description" : "To enable any captions in the video(default language of caption is English)"
},
"volume": {
"type": "integer",
"description" : "Changes the volume. (max = 100, min = 0)"
},
"videoPosition": {
"type": "boolean",
"description": "To add an indicator for the amount of video that is completed"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion lib/util/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class Utils {
}

static List<YamlMap>? getListOfYamlMap(dynamic value) {
if (value is YamlList) {
if (value is YamlList || value is List) {
List<YamlMap> results = [];
for (var item in value) {
if (item is YamlMap) {
Expand Down
43 changes: 26 additions & 17 deletions lib/widget/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class EnsembleCalendar extends StatefulWidget
_controller.headerTextStyle = Utils.getTextStyle(value),
'header': (value) => _controller.header = value,
'tootlip': (value) => setTooltip(value),
'showTooltip': (value) =>
_controller.showTooltip = Utils.getBool(value, fallback: false)
};
}

Expand Down Expand Up @@ -463,6 +465,7 @@ class CalendarController extends WidgetController {
DateTime? tooltipDate;
TextStyle? tooltipTextStyle;
Color? tooltipBackgroundColor;
bool showTooltip = false;

final ValueNotifier<Set<DateTime>> markedDays = ValueNotifier(
LinkedHashSet<DateTime>(
Expand Down Expand Up @@ -493,23 +496,24 @@ class CalendarState extends WidgetState<EnsembleCalendar> {

@override
void initState() {
widget._controller.selectedDays.addListener(() {
setState(() {});
});

widget._controller.markedDays.addListener(() {
setState(() {});
});

widget._controller.disableDays.addListener(() {
setState(() {});
});
widget._controller.selectedDays.addListener(listener);
widget._controller.markedDays.addListener(listener);
widget._controller.disableDays.addListener(listener);
widget._controller.rowSpans.addListener(listener);
super.initState();
}

widget._controller.rowSpans.addListener(() {
setState(() {});
});
void listener() {
setState(() {});
}

super.initState();
@override
void dispose() {
widget._controller.selectedDays.removeListener(listener);
widget._controller.markedDays.removeListener(listener);
widget._controller.disableDays.removeListener(listener);
widget._controller.rowSpans.removeListener(listener);
super.dispose();
}

void _onDaySelected(DateTime selectedDay, DateTime focusedDay) {
Expand Down Expand Up @@ -636,13 +640,18 @@ class CalendarState extends WidgetState<EnsembleCalendar> {
toolTip: widget._controller.tooltip,
toolTipBackgroundColor: widget._controller.tooltipBackgroundColor,
toolTipStyle: widget._controller.tooltipTextStyle,
showTooltip: widget._controller.showTooltip,
calendarBuilders: CalendarBuilders(
overlayDefaultBuilder: (context) {
overlayDefaultBuilder: (context, collapsedLength) {
Map<String, dynamic> data = {};
if (collapsedLength != null) {
data['collapsedLength'] = collapsedLength;
}
if (widget._controller.overlapOverflowBuilder == null) {
return null;
}
return widgetBuilder(
context, widget._controller.overlapOverflowBuilder, {});
context, widget._controller.overlapOverflowBuilder, data);
},
overlayBuilder: widget._controller.rowSpans.value.isEmpty
? null
Expand Down
66 changes: 52 additions & 14 deletions lib/widget/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import 'package:ensemble/framework/action.dart' as ensemble;
import 'package:yaml/yaml.dart';

class CSSStyle {
StringBuffer cssBuffer;
Map<String, Map<String, dynamic>> cssMap;

CSSStyle._({required this.cssBuffer, required this.cssMap});

factory CSSStyle.fromYaml(List<YamlMap> yaml) {
Expand Down Expand Up @@ -47,6 +44,13 @@ class CSSStyle {
return CSSStyle._(cssBuffer: rtnCssBuffer, cssMap: rtnCssMap);
}

StringBuffer cssBuffer;
Map<String, Map<String, dynamic>> cssMap;

void updateMaxLines(String selector, int maxLines) {
cssMap[selector]?['maxLines'] = maxLines;
}

Map<String, Style> getStyle() {
Map<String, Style> style = Style.fromCss(
cssBuffer.toString(),
Expand All @@ -66,8 +70,9 @@ class CSSStyle {
if (containsMatch) {
style[key] = style[key]!.copyWith(
maxLines: value['maxLines'],
textOverflow: TextOverflow.values.asNameMap()['textOverflow'],
textTransform: TextTransform.values.asNameMap()['textTransform'],
textOverflow: TextOverflow.values.asNameMap()[value['textOverflow']],
textTransform:
TextTransform.values.asNameMap()[value['textTransform']],
);
}
});
Expand All @@ -79,10 +84,12 @@ class CSSStyle {
/// widget to render Html content
class EnsembleHtml extends StatefulWidget
with Invokable, HasController<HtmlController, HtmlState> {
static const type = 'Html';
EnsembleHtml({Key? key}) : super(key: key);

static const type = 'Html';

final HtmlController _controller = HtmlController();

@override
HtmlController get controller => _controller;

Expand All @@ -94,6 +101,14 @@ class EnsembleHtml extends StatefulWidget
return {'text': () => _controller.text};
}

@override
Map<String, Function> methods() {
return {
// Updates the max lines for a given selector. Takes two attributes as selector and maxLines
'updateMaxLines': controller.htmlAction!.updateMaxLines,
};
}

@override
Map<String, Function> setters() {
return {
Expand All @@ -107,21 +122,44 @@ class EnsembleHtml extends StatefulWidget
},
};
}

@override
Map<String, Function> methods() {
return {};
}
}

class HtmlController extends BoxController {
String? text;
CSSStyle? cssStyle;
ensemble.EnsembleAction? onLinkTap;
String? text;

CSSStyle? cssStyle;
// Added action so it becomes easy to add additional methods in future
HtmlAction? htmlAction;
}

mixin HtmlAction on framework.WidgetState<EnsembleHtml> {
void updateMaxLines(String selector, int maxLines);
}

class HtmlState extends framework.WidgetState<EnsembleHtml> {
class HtmlState extends framework.WidgetState<EnsembleHtml> with HtmlAction {
@override
void updateMaxLines(String selector, int maxLines) {
// Need to add it here to be able to do setState
setState(() {
widget.controller.cssStyle?.updateMaxLines(selector, maxLines);
});
}

@override
void didChangeDependencies() {
super.didChangeDependencies();

widget.controller.htmlAction = this;
}

@override
void didUpdateWidget(covariant EnsembleHtml oldWidget) {
super.didUpdateWidget(oldWidget);

widget.controller.htmlAction = this;
}

@override
Widget buildWidget(BuildContext context) {
return BoxWrapper(
Expand Down
Loading

0 comments on commit dbbb290

Please sign in to comment.