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

feat: check feature compatibility with appnexus flutter (fixes #13) #14

Merged
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ melos run run:example -- -d sdk # android

- [xandr ios SDK](https://github.com/appnexus/mobile-sdk-ios)
- [xandr android SDK](https://github.com/appnexus/mobile-sdk-android)
- [deprecated appnexus flutter integration](https://github.com/schibsted/appnexus-flutter)

### tooling

Expand Down
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"thekorn",
"webdesktop",
"webphone",
"xandr"
"xandr",
"appnexus"
]
}
Binary file modified docs/images/android_sample1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
221 changes: 167 additions & 54 deletions packages/xandr/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:xandr/ad_banner.dart';
import 'package:xandr/ad_size.dart';
import 'package:xandr/load_mode.dart';
import 'package:xandr/xandr.dart';
import 'package:xandr/xandr_builder.dart';

Expand Down Expand Up @@ -34,12 +37,25 @@ class XandrExample extends StatefulWidget {

class _XandrExampleState extends State<XandrExample> {
late final XandrController _controller;
final ScrollController _scrollController = ScrollController();
final StreamController<ScrollPosition> _checkIfAdIsInViewport =
StreamController();

@override
void dispose() {
_scrollController.dispose();
_checkIfAdIsInViewport.close();
super.dispose();
}

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

_controller = XandrController();
_scrollController.addListener(() {
_checkIfAdIsInViewport.add(_scrollController.position);
});
}

@override
Expand All @@ -56,60 +72,157 @@ class _XandrExampleState extends State<XandrExample> {
builder: (context, snapshot) {
if (snapshot.hasData) {
debugPrint('Xandr SDK initialized, success=${snapshot.hasData}');
return Column(
children: [
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to make'),
AdBanner(
controller: _controller,
//placementID: '17058950',
inventoryCode: 'bunte_webdesktop_home_homepage_hor_1',
adSizes: const [
AdSize(1, 1),
AdSize(728, 90),
], //[AdSize(300, 250)],
width: 90,
height: 90,
//customKeywords: useDemoAds,
),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to make'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to make'),
AdBanner(
controller: _controller,
//placementID: '17058950',
inventoryCode: 'bunte_webdesktop_home_homepage_hor_1',
adSizes: const [AdSize(728, 90)], //[AdSize(300, 250)],
//customKeywords: useDemoAds,
width: 90,
height: 90,
),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to make'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to make'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to make'),
],
return SingleChildScrollView(
controller: _scrollController,
child: Column(
children: [
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to m'),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: Align(
alignment: Alignment.topLeft,
child: Text(
'fit to container:',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
AdBanner(
controller: _controller,
//placementID: '17058950',
inventoryCode: 'bunte_webdesktop_home_homepage_hor_1',
adSizes: const [AdSize(728, 90)], //[AdSize(300, 250)],
//customKeywords: useDemoAds,
resizeAdToFitContainer: true,
),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to n'),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: Align(
alignment: Alignment.topLeft,
child: Text(
'crop to reserved space:',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
AdBanner(
controller: _controller,
//placementID: '17058950',
inventoryCode: 'bunte_webdesktop_home_homepage_hor_1',
adSizes: const [
AdSize(1, 1),
AdSize(728, 90),
], //[AdSize(300, 250)],
width: 90,
height: 90,
//customKeywords: useDemoAds,
resizeWhenLoaded: true,
),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to v'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to v'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to v'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to v'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to v'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to v'),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: Align(
alignment: Alignment.topLeft,
child: Text(
'use winning ad size:',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
AdBanner(
controller: _controller,
//placementID: '17058950',
inventoryCode: 'bunte_webdesktop_home_homepage_hor_1',
adSizes: const [
AdSize(1, 1),
AdSize(728, 90),
], //[AdSize(300, 250)],
width: 90,
height: 90,
loadsInBackground: true,
),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to g'),
const Text(
'Lorem Ipsum is simply dummy text of the printing and '
'typesetting industry. Lorem Ipsum has been the boo '
'standard dummy text ever since the 1500s, when an aha '
'printer took a galley of type and scrambled it to g'),
const Padding(
padding: EdgeInsets.symmetric(vertical: 8),
child: Align(
alignment: Alignment.topLeft,
child: Text(
'load when in viewport:',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
),
AdBanner(
controller: _controller,
//placementID: '17058950',
inventoryCode: 'bunte_webdesktop_home_homepage_hor_1',
adSizes: const [
AdSize(1, 1),
AdSize(728, 90),
], //[AdSize(300, 250)],
resizeAdToFitContainer: true,
loadMode: LoadMode.whenInViewport(
_checkIfAdIsInViewport.stream,
-100,
),
),
],
),
);
} else if (snapshot.hasError) {
return const Text('Error initializing Xandr SDK');
Expand Down
Loading
Loading