-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfce58e
commit f26b7ff
Showing
9 changed files
with
433 additions
and
93 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
## [0.0.3] - 01/06/2018 | ||
|
||
* BSD License | ||
* API Docs | ||
* API Docs | ||
* Child property is now required for Button widget. |
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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: native_ui | ||
description: NativeUI widgets for Android and iOS | ||
version: 0.0.2 | ||
version: 0.0.3 | ||
author: Carlos A. Escobar <[email protected]> | ||
homepage: https://github.com | ||
|
||
|
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,63 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/rendering.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:native_ui/native_ui.dart'; | ||
|
||
const TextStyle testStyle = const TextStyle( | ||
fontFamily: 'Ahem', | ||
fontSize: 10.0, | ||
); | ||
|
||
void main() { | ||
testWidgets('Button wrapper renders MaterialButton when TargetPlatform is Android', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
Theme( | ||
data: ThemeData( | ||
platform: TargetPlatform.android, | ||
), | ||
child: boilerplate( | ||
child: Button( | ||
child: Text( | ||
'X', | ||
style: testStyle, | ||
), | ||
onPressed: null, | ||
), | ||
), | ||
), | ||
); | ||
final RenderBox button = tester.renderObject(find.byType(MaterialButton)); | ||
expect( | ||
button.size, | ||
const Size(88.0, 36.0), | ||
); | ||
}); | ||
|
||
testWidgets('Button wrapper renders iOSButton when TargetPlatform is iOS', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
Theme( | ||
data: ThemeData( | ||
platform: TargetPlatform.iOS, | ||
), | ||
child: boilerplate( | ||
child: Button( | ||
child: const Text('X', style: testStyle), | ||
onPressed: null, | ||
), | ||
), | ||
), | ||
); | ||
final RenderBox button = tester.renderObject(find.byType(iOSButton)); | ||
expect( | ||
button.size, | ||
const Size.square(44.0), | ||
); | ||
}); | ||
} | ||
|
||
Widget boilerplate({Widget child}) { | ||
return new Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: new Center(child: child), | ||
); | ||
} |
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,43 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/rendering.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:native_ui/native_ui.dart'; | ||
|
||
void main() { | ||
testWidgets('Does renders trueWidget when condition is true', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
boilerplate( | ||
child: const ConditionalBuilder( | ||
condition: true, | ||
trueWidget: const Text('True'), | ||
falseWidget: const Text('False'))), | ||
); | ||
final RenderParagraph textWidget = tester.renderObject(find.byType(Text)); | ||
expect( | ||
textWidget.text.text, | ||
'True', | ||
); | ||
}); | ||
|
||
testWidgets('Does renders falseWidget when condition is false', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
boilerplate( | ||
child: const ConditionalBuilder( | ||
condition: false, | ||
trueWidget: const Text('True'), | ||
falseWidget: const Text('False'))), | ||
); | ||
final RenderParagraph textWidget = tester.renderObject(find.byType(Text)); | ||
expect( | ||
textWidget.text.text, | ||
'False', | ||
); | ||
}); | ||
} | ||
|
||
Widget boilerplate({Widget child}) { | ||
return new Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: new Center(child: child), | ||
); | ||
} |
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,73 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/rendering.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:native_ui/native_ui.dart'; | ||
|
||
void main() { | ||
testWidgets('Android platform', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
Theme( | ||
data: ThemeData( | ||
platform: TargetPlatform.android, | ||
), | ||
child: boilerplate( | ||
child: PlatformSwitcher( | ||
androidChild: new Text('Android'), | ||
iOSChild: new Text('iOS'), | ||
fuchsiaChild: new Text('fuchsia'), | ||
), | ||
), | ||
), | ||
); | ||
final RenderParagraph textWidget = tester.renderObject(find.byType(Text)); | ||
expect(textWidget.text.text, 'Android'); | ||
}); | ||
|
||
testWidgets('iOS platform', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
Theme( | ||
data: ThemeData( | ||
platform: TargetPlatform.iOS, | ||
), | ||
child: boilerplate( | ||
child: PlatformSwitcher( | ||
androidChild: new Text('Android'), | ||
iOSChild: new Text('iOS'), | ||
fuchsiaChild: new Text('fuchsia'), | ||
), | ||
), | ||
), | ||
); | ||
final RenderParagraph textWidget = tester.renderObject(find.byType(Text)); | ||
expect(textWidget.text.text, 'iOS'); | ||
}); | ||
|
||
testWidgets('fucshia platform', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
Theme( | ||
data: ThemeData( | ||
platform: TargetPlatform.fuchsia, | ||
), | ||
child: boilerplate( | ||
child: PlatformSwitcher( | ||
androidChild: new Text('Android'), | ||
iOSChild: new Text('iOS'), | ||
fuchsiaChild: new Text('fuchsia'), | ||
), | ||
), | ||
), | ||
); | ||
final RenderParagraph textWidget = tester.renderObject(find.byType(Text)); | ||
expect( | ||
textWidget.text.text, | ||
'fuchsia', | ||
); | ||
}); | ||
} | ||
|
||
Widget boilerplate({Widget child}) { | ||
return new Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: new Center(child: child), | ||
); | ||
} |