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

fontFamily now properly propagates to all widgets. Refactored Buttons… #1519

Open
wants to merge 2 commits into
base: main
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
93 changes: 51 additions & 42 deletions modules/ensemble/lib/action/get_network_info_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,33 @@ class GetNetworkInfoAction extends EnsembleAction {
EnsembleAction? onDenied;
EnsembleAction? onLocationDisabled;

GetNetworkInfoAction({super.initiator,
super.inputs,
this.onSuccess,
this.onError,
this.onDenied,
this.onLocationDisabled});
GetNetworkInfoAction(
{super.initiator,
super.inputs,
this.onSuccess,
this.onError,
this.onDenied,
this.onLocationDisabled});

factory GetNetworkInfoAction.from({Invokable? initiator,dynamic payload}) =>
GetNetworkInfoAction.fromYaml(initiator: initiator, payload: Utils.getYamlMap(payload));
factory GetNetworkInfoAction.from({Invokable? initiator, dynamic payload}) =>
GetNetworkInfoAction.fromYaml(
initiator: initiator, payload: Utils.getYamlMap(payload));
factory GetNetworkInfoAction.fromYaml({Invokable? initiator, Map? payload}) {
if (payload?['onSuccess'] == null) {
throw LanguageError('onSuccess is required',recovery:'Please specify onSuccess method to call when network info is retrieved');
throw LanguageError('onSuccess is required',
recovery:
'Please specify onSuccess method to call when network info is retrieved');
}
return GetNetworkInfoAction(
initiator: initiator,
inputs: Utils.getMap(payload?['inputs']),
onSuccess: EnsembleAction.from(payload?['onSuccess'], initiator: initiator),
onSuccess:
EnsembleAction.from(payload?['onSuccess'], initiator: initiator),
onError: EnsembleAction.from(payload?['onError'], initiator: initiator),
onDenied: EnsembleAction.from(payload?['onDenied'], initiator: initiator),
onLocationDisabled: EnsembleAction.from(payload?['onLocationDisabled'], initiator: initiator));
onDenied:
EnsembleAction.from(payload?['onDenied'], initiator: initiator),
onLocationDisabled: EnsembleAction.from(payload?['onLocationDisabled'],
initiator: initiator));
}

@override
Expand All @@ -51,35 +58,31 @@ class GetNetworkInfoAction extends EnsembleAction {
data: {'status': 'error'}));
}
networkInfo.getLocationStatus().then((locationStatus) {
if ((locationStatus == LocationPermissionStatus.denied.name
|| locationStatus == LocationPermissionStatus.deniedForever.name)
&& onDenied != null) {
if ((locationStatus == LocationPermissionStatus.denied.name ||
locationStatus == LocationPermissionStatus.deniedForever.name) &&
onDenied != null) {
return ScreenController().executeAction(context, onDenied!,
event: EnsembleEvent(initiator,
data: {'status': locationStatus}));
} else if (locationStatus == LocationStatus.disabled.name
&& onLocationDisabled != null) {
event: EnsembleEvent(initiator, data: {'status': locationStatus}));
} else if (locationStatus == LocationStatus.disabled.name &&
onLocationDisabled != null) {
return ScreenController().executeAction(context, onLocationDisabled!,
event: EnsembleEvent(initiator,
data: {'status': locationStatus}));
} else
if (locationStatus == LocationPermissionStatus.unableToDetermine.name
&& onError != null) {
event: EnsembleEvent(initiator, data: {'status': locationStatus}));
} else if (locationStatus ==
LocationPermissionStatus.unableToDetermine.name &&
onError != null) {
return ScreenController().executeAction(context, onError!,
event: EnsembleEvent(initiator,
data: {
'status': locationStatus
}));
event: EnsembleEvent(initiator, data: {'status': locationStatus}));
} else {
try {
networkInfo.getNetworkInfo().then((info) =>
ScreenController().executeAction(context, onSuccess!,
event: EnsembleEvent(initiator,
data: {
networkInfo
.getNetworkInfo()
.then((info) =>
ScreenController().executeAction(context, onSuccess!,
event: EnsembleEvent(initiator, data: {
'status': locationStatus,
'networkInfo': info,
}
))).onError((error, stackTrace) {
})))
.onError((error, stackTrace) {
if (onError != null) {
return ScreenController().executeAction(context, onError!,
event: EnsembleEvent(initiator,
Expand All @@ -91,25 +94,32 @@ class GetNetworkInfoAction extends EnsembleAction {
if (onError != null) {
return ScreenController().executeAction(context, onError!,
event: EnsembleEvent(initiator,
error: e.toString(),
data: {'status': locationStatus}));
error: e.toString(), data: {'status': locationStatus}));
}
}
}
}).onError((e, stackTrace) {
if (onError != null) {
return ScreenController().executeAction(context, onError!,
event: EnsembleEvent(initiator,
error: e.toString(),
data: {'status': 'error: '+e.toString(), 'networkInfo': null}));
event: EnsembleEvent(initiator, error: e.toString(), data: {
'status': 'error: ' + e.toString(),
'networkInfo': null
}));
}
print('Failed to get location status: $e');
});
return Future.value(null);
}
}

class InvokableNetworkInfo extends Object with Invokable {
String? wifiName,wifiIPv6,wifiIPv4,wifiGatewayIP,wifiSubmask,wifiBroadcast,wifiBSSID;
String? wifiName,
wifiIPv6,
wifiIPv4,
wifiGatewayIP,
wifiSubmask,
wifiBroadcast,
wifiBSSID;
InvokableNetworkInfo({
this.wifiName,
this.wifiIPv4,
Expand All @@ -120,7 +130,6 @@ class InvokableNetworkInfo extends Object with Invokable {
this.wifiBSSID,
});


@override
Map<String, Function> getters() {
return {
Expand All @@ -143,4 +152,4 @@ class InvokableNetworkInfo extends Object with Invokable {
Map<String, Function> setters() {
return {};
}
}
}
6 changes: 3 additions & 3 deletions modules/ensemble/lib/framework/stub/network_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ abstract class NetworkInfoManager {
}

class NetworkInfoManagerStub implements NetworkInfoManager {
NetworkInfoManagerStub() {
}
NetworkInfoManagerStub() {}
@override
Future<InvokableNetworkInfo> getNetworkInfo() {
if (kIsWeb) {
Expand All @@ -22,6 +21,7 @@ class NetworkInfoManagerStub implements NetworkInfoManager {
throw ConfigError(
"NetworkInfo module is not enabled. Please review the Ensemble documentation.");
}

@override
Future<LocationPermissionStatus> checkPermission() {
throw ConfigError(
Expand All @@ -33,4 +33,4 @@ class NetworkInfoManagerStub implements NetworkInfoManager {
throw ConfigError(
"NetworkInfo module is not enabled. Please review the Ensemble documentation.");
}
}
}
Loading
Loading