Skip to content

Commit

Permalink
Merge branch 'textInput-Reader-Accessibility' of https://github.com/E…
Browse files Browse the repository at this point in the history
…nsembleUI/ensemble into textInput-Reader-Accessibility
  • Loading branch information
Umair-Manzoor-47 committed Feb 21, 2025
2 parents de67d12 + 4827a68 commit 9365e0b
Show file tree
Hide file tree
Showing 23 changed files with 208 additions and 29 deletions.
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,52 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2025-02-20

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`ensemble` - `v1.1.24`](#ensemble---v1124)
- [`ensemble_contacts` - `v0.0.1+1`](#ensemble_contacts---v0011)
- [`ensemble_location` - `v0.0.1+1`](#ensemble_location---v0011)
- [`ensemble_chat` - `v0.0.1+1`](#ensemble_chat---v0011)
- [`ensemble_file_manager` - `v0.0.1+1`](#ensemble_file_manager---v0011)
- [`ensemble_auth` - `v1.0.1`](#ensemble_auth---v101)
- [`ensemble_connect` - `v0.0.1+1`](#ensemble_connect---v0011)
- [`ensemble_deeplink` - `v0.0.1+1`](#ensemble_deeplink---v0011)
- [`ensemble_network_info` - `v0.0.1+1`](#ensemble_network_info---v0011)
- [`ensemble_camera` - `v0.0.1+1`](#ensemble_camera---v0011)
- [`ensemble_bluetooth` - `v0.0.1+1`](#ensemble_bluetooth---v0011)

Packages with dependency updates only:

> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `ensemble_contacts` - `v0.0.1+1`
- `ensemble_location` - `v0.0.1+1`
- `ensemble_chat` - `v0.0.1+1`
- `ensemble_file_manager` - `v0.0.1+1`
- `ensemble_auth` - `v1.0.1`
- `ensemble_connect` - `v0.0.1+1`
- `ensemble_deeplink` - `v0.0.1+1`
- `ensemble_network_info` - `v0.0.1+1`
- `ensemble_camera` - `v0.0.1+1`
- `ensemble_bluetooth` - `v0.0.1+1`

---

#### `ensemble` - `v1.1.24`

- Bump "ensemble" to `1.1.24`.


## 2025-02-19

### Changes
Expand Down
2 changes: 1 addition & 1 deletion modules/auth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

ensemble_ts_interpreter:
Expand Down
2 changes: 1 addition & 1 deletion modules/bracket/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion modules/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble
ensemble_ts_interpreter:
git:
Expand Down
2 changes: 1 addition & 1 deletion modules/chat/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

ensemble_ts_interpreter:
Expand Down
2 changes: 1 addition & 1 deletion modules/connect/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

plaid_flutter: ^3.1.2
Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

flutter_contacts: ^1.1.7+1
Expand Down
2 changes: 1 addition & 1 deletion modules/deeplink/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

flutter_branch_sdk: ^7.0.1
Expand Down
4 changes: 4 additions & 0 deletions modules/ensemble/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.24

- Bump "ensemble" to `1.1.24`.

## 1.1.23

## 1.1.22
Expand Down
29 changes: 29 additions & 0 deletions modules/ensemble/lib/framework/bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ abstract class BindingSource {
String binding, DataContext dataContext) {
RegExp variableNameRegex = RegExp('^[0-9a-z_]+', caseSensitive: false);

// Check for device bindings (both patterns)
String deviceExpr = 'ensemble.device.';
if (binding.startsWith(deviceExpr)) {
// For ensemble.device.property pattern
String property = binding.substring(deviceExpr.length);
return DeviceBindingSource(property);
} else if (binding.startsWith('device.')) {
// For device.property pattern
String property = binding.substring('device.'.length);
return DeviceBindingSource(property);
}

// bindable storage
String storageExpr = 'ensemble.storage.';
String userExpr = 'ensemble.user.';
Expand Down Expand Up @@ -121,6 +133,18 @@ abstract class BindingSource {
String variable = expression.substring(2, expression.length - 1).trim();
RegExp variableNameRegex = RegExp('^[0-9a-z_]+', caseSensitive: false);

// Check for device bindings (both patterns)
String deviceExpr = 'ensemble.device.';
if (variable.startsWith(deviceExpr)) {
// For ensemble.device.property pattern
String property = variable.substring(deviceExpr.length);
return DeviceBindingSource(property);
} else if (variable.startsWith('device.')) {
// For device.property pattern
String property = variable.substring('device.'.length);
return DeviceBindingSource(property);
}

// storage bindable
String storageExpr = 'ensemble.storage.';
String userExpr = 'ensemble.user.';
Expand Down Expand Up @@ -202,6 +226,11 @@ class StorageBindingSource extends BindingSource {
StorageBindingSource(super.modelId);
}

/// bindable source backed by device
class DeviceBindingSource extends BindingSource {
DeviceBindingSource(super.modelId);
}

/// TODO: consolidate this with StorageBindingSource
class SystemStorageBindingSource extends BindingSource {
SystemStorageBindingSource(super.modelId, {required this.storagePrefix});
Expand Down
14 changes: 9 additions & 5 deletions modules/ensemble/lib/framework/data_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,19 @@ class DataContext implements Context {
_contextMap['auth'] = GetIt.instance<AuthContextManager>();
}

_addLegacyDataContext();
_addLegacyDataContext(buildContext);
}

// For backward compatibility
void _addLegacyDataContext() {

// device is a common name. If user already uses that, don't override it
// This is now in ensemble.device.*
void _addLegacyDataContext(BuildContext? newBuildContext) {
if (_contextMap['device'] == null) {
_contextMap['device'] = Device();
_contextMap['device'] = Device(newBuildContext);
} else {
// If device exists, update its context
final device = _contextMap['device'];
device.updateContext(newBuildContext);
}
}

Expand Down Expand Up @@ -468,7 +472,7 @@ class NativeInvokable extends ActionInvokable {
'user': () => UserInfo(),
'formatter': () => Formatter(),
'utils': () => _EnsembleUtils(),
'device': () => Device(),
'device': () => Device(buildContext),
'version': () => _cache['version'],
};
}
Expand Down
55 changes: 48 additions & 7 deletions modules/ensemble/lib/framework/device.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:core';
import 'dart:io';
import 'dart:developer';
Expand All @@ -14,24 +15,64 @@ import 'package:ensemble_ts_interpreter/invokables/invokable.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:get_it/get_it.dart';
import 'package:intl/intl.dart';

/// get device information as well as requesting device permissions
class Device
with
Invokable,
MediaQueryCapability,
LocationCapability,
DeviceInfoCapability {
DeviceInfoCapability,
WidgetsBindingObserver {
static final Device _instance = Device._internal();
static late BuildContext context;

Device._internal();
Device._internal() {
WidgetsBinding.instance.addObserver(this);
}

factory Device() {
factory Device([BuildContext? buildContext]) {
if (buildContext != null) {
context = buildContext;
}
return _instance;
}

// method to update context
void updateContext(BuildContext? newContext) {
if (newContext != null) {
context = newContext;
}
}

@override
void didChangeMetrics() {
WidgetsBinding.instance
.addPostFrameCallback((_) => _handleMediaQueryChange());
}

void _handleMediaQueryChange() {
final newData = MediaQuery.of(context);

// Compare with existing static data
if (MediaQueryCapability.data?.orientation != newData.orientation ||
MediaQueryCapability.data?.size != newData.size) {
MediaQueryCapability.data = newData;

// Dispatch individual property changes
ScreenController().dispatchDeviceChanges(context, 'width', screenWidth);
ScreenController().dispatchDeviceChanges(context, 'height', screenHeight);
ScreenController()
.dispatchDeviceChanges(context, 'orientation', screenOrientation);
ScreenController()
.dispatchDeviceChanges(context, 'safeAreaTop', safeAreaTop);
ScreenController()
.dispatchDeviceChanges(context, 'safeAreaBottom', safeAreaBottom);
}
}

@override
Map<String, Function> getters() {
return {
Expand All @@ -42,6 +83,7 @@ class Device
// Media Query
"width": () => screenWidth,
"height": () => screenHeight,
"orientation": () => screenOrientation,
"safeAreaTop": () => safeAreaTop,
"safeAreaBottom": () => safeAreaBottom,

Expand Down Expand Up @@ -73,9 +115,7 @@ class Device
}

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

void openAppSettings([String? target]) {
final settingType =
Expand All @@ -96,6 +136,7 @@ mixin MediaQueryCapability {

int get screenWidth => _getData().size.width.toInt();
int get screenHeight => _getData().size.height.toInt();
String get screenOrientation => _getData().orientation.toString();
int get safeAreaTop => _getData().padding.top.toInt();
int get safeAreaBottom => _getData().padding.bottom.toInt();
}
Expand Down
10 changes: 10 additions & 0 deletions modules/ensemble/lib/screen_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,16 @@ class ScreenController {
}
}

void dispatchDeviceChanges(
BuildContext context, String property, dynamic value) {
ScopeManager? scopeManager = getScopeManager(context);

if (scopeManager != null) {
scopeManager
.dispatch(ModelChangeEvent(DeviceBindingSource(property), value));
}
}

void dispatchSystemStorageChanges(
BuildContext context, String key, dynamic value,
{required String storagePrefix}) {
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description: Ensemble Runtime
# This version is used _only_ for the Runner app, which is used if you just do
# a `flutter run` or a `flutter make-host-app-editable`. It has no impact
# on any other native host app that you embed your Flutter project into.
version: 1.1.23
version: 1.1.24

environment:
sdk: ">=3.5.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble_bluetooth/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble
ensemble_ts_interpreter:
git:
Expand Down
2 changes: 1 addition & 1 deletion modules/ensemble_network_info/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

network_info_plus: ^5.0.3
Expand Down
2 changes: 1 addition & 1 deletion modules/file_manager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble
ensemble_ts_interpreter:
git:
Expand Down
2 changes: 1 addition & 1 deletion modules/firebase_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
ensemble:
git:
url: https://github.com/EnsembleUI/ensemble.git
ref: ensemble-v1.1.23
ref: ensemble-v1.1.24
path: modules/ensemble

dev_dependencies:
Expand Down
9 changes: 9 additions & 0 deletions modules/location/lib/widget/maps/maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class EnsembleMapWidget extends StatefulWidget
_controller.toolbarRight = Utils.optionalInt(value, min: 0),

'mapType': (value) => _controller.mapType = value,
'fixedMarker': (value) => _controller.fixedMarker =
Utils.getBool(value, fallback: _controller.fixedMarker),
'draggableMarker': (value) => _controller.draggableMarker =
Utils.getBool(value, fallback: _controller.draggableMarker),
'markers': (markerData) => setMarkers(markerData),
'scrollableMarkerOverlay': (value) => _controller
.scrollableMarkerOverlay =
Expand Down Expand Up @@ -185,6 +189,11 @@ class MyController extends WidgetController with LocationCapability {
bool tiltEnabled = true;
bool zoomEnabled = true;

// Determines whether the marker remains fixed at the center of the map when the user moves the map.
bool fixedMarker = false;
// Determines whether the marker can be dragged by the user.
bool draggableMarker = false;

// toolbar has multiple button options
bool showToolbar = true;
bool showMapTypesButton = true;
Expand Down
Loading

0 comments on commit 9365e0b

Please sign in to comment.