Skip to content

Commit

Permalink
Format project
Browse files Browse the repository at this point in the history
  • Loading branch information
iAmWillShepherd committed Aug 29, 2022
1 parent 376dfb7 commit f1c6f27
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: flutter analyze --no-pub --no-fatal-infos

- name: Ensure the Dart code is formatted correctly
run: flutter format -o json --set-exit-if-changed .
run: flutter format -o none --set-exit-if-changed .

- name: Run Flutter unit tests
run: flutter test
8 changes: 2 additions & 6 deletions lib/src/in_app_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:onesignal_flutter/src/utils.dart';
/// the handler returns an OSInAppMessageAction object so the Dart code can act accordingly
/// This allows for custom action events within Dart
class OSInAppMessageAction extends JSONStringRepresentable {

// Name of the action event defined for the IAM element
String? clickName;

Expand Down Expand Up @@ -32,19 +31,16 @@ class OSInAppMessageAction extends JSONStringRepresentable {
'closes_message': this.closesMessage,
});
}

}

class OSInAppMessage extends JSONStringRepresentable {
String? messageId;

OSInAppMessage(Map<String, dynamic> json) {
this.messageId = json["message_id"];
}
}

String jsonRepresentation() {
return convertToJsonString({
'message_id': this.messageId
});
return convertToJsonString({'message_id': this.messageId});
}
}
8 changes: 5 additions & 3 deletions lib/src/permission.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class OSPermissionStateChanges extends JSONStringRepresentable {
}

class OSDeviceState extends JSONStringRepresentable {

bool hasNotificationPermission = false;
bool pushDisabled = false;
bool subscribed = false;
Expand All @@ -110,7 +109,10 @@ class OSDeviceState extends JSONStringRepresentable {
this.emailAddress = json['emailAddress'] as String?;
this.smsUserId = json['smsUserId'] as String?;
this.smsNumber = json['smsNumber'] as String?;
this.notificationPermissionStatus = json['notificationPermissionStatus'] == null ? null : OSNotificationPermission.values[json['notificationPermissionStatus']];
this.notificationPermissionStatus = json['notificationPermissionStatus'] ==
null
? null
: OSNotificationPermission.values[json['notificationPermissionStatus']];
}

String jsonRepresentation() {
Expand All @@ -129,4 +131,4 @@ class OSDeviceState extends JSONStringRepresentable {
'notificationPermissionStatus': this.notificationPermissionStatus?.index,
});
}
}
}
5 changes: 3 additions & 2 deletions lib/src/subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ class OSEmailSubscriptionStateChanges extends JSONStringRepresentable {

OSEmailSubscriptionStateChanges(Map<String, dynamic> json) {
if (json.containsKey('from'))
this.from = OSEmailSubscriptionState(json['from'].cast<String, dynamic>());
this.from =
OSEmailSubscriptionState(json['from'].cast<String, dynamic>());
if (json.containsKey('to'))
this.to = OSEmailSubscriptionState(json['to'].cast<String, dynamic>());
}
Expand Down Expand Up @@ -151,4 +152,4 @@ class OSSMSSubscriptionStateChanges extends JSONStringRepresentable {
'to': this.to.jsonRepresentation()
});
}
}
}
26 changes: 13 additions & 13 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ dynamic convertEnumCaseToValue(dynamic key) {
}

switch (key) {
case OSSession.DIRECT:
return "DIRECT";
case OSSession.INDIRECT:
return "INDIRECT";
case OSSession.UNATTRIBUTED:
return "UNATTRIBUTED";
case OSSession.DISABLED:
return "DISABLED";
case OSSession.DIRECT:
return "DIRECT";
case OSSession.INDIRECT:
return "INDIRECT";
case OSSession.UNATTRIBUTED:
return "UNATTRIBUTED";
case OSSession.DISABLED:
return "DISABLED";
}

return key;
Expand All @@ -78,9 +78,9 @@ dynamic convertEnumCaseToValue(dynamic key) {
abstract class JSONStringRepresentable {
String jsonRepresentation();

String convertToJsonString(Map<String, dynamic>? object) => JsonEncoder
.withIndent(' ')
.convert(object)
.replaceAll("\\n", "\n")
.replaceAll("\\", "");
String convertToJsonString(Map<String, dynamic>? object) =>
JsonEncoder.withIndent(' ')
.convert(object)
.replaceAll("\\n", "\n")
.replaceAll("\\", "");
}
4 changes: 2 additions & 2 deletions test/onesignalflutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:onesignal_flutter/onesignal_flutter.dart';
import 'mock_channel.dart';
import 'test_data.dart';


void main() {
TestWidgetsFlutterBinding.ensureInitialized();

Expand Down Expand Up @@ -55,7 +54,8 @@ void main() {
}).then(expectAsync1((v) {
expect(channelController.state.postNotificationJson!['content_available'],
true);
expect(channelController.state.postNotificationJson!['include_player_ids'],
expect(
channelController.state.postNotificationJson!['include_player_ids'],
[testPlayerId]);
}));
});
Expand Down

0 comments on commit f1c6f27

Please sign in to comment.