-
Notifications
You must be signed in to change notification settings - Fork 17
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
Showing
25 changed files
with
602 additions
and
33 deletions.
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
2 changes: 1 addition & 1 deletion
2
example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_pangle_ads/flutter_pangle_ads.dart'; | ||
|
||
import '../ads_config.dart'; | ||
import '../widgets/widgets.dart'; | ||
|
||
class BannerPage extends StatefulWidget { | ||
const BannerPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
_BannerPageState createState() => _BannerPageState(); | ||
} | ||
|
||
class _BannerPageState extends State<BannerPage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: buildAppBar(context, 'Banner广告'), | ||
body: Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
SizedBox(height: 20), | ||
AdBannerWidget( | ||
posId: AdsConfig.bannerId, | ||
width: 300, | ||
height: 80, | ||
interval: 30, | ||
show: true, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
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,169 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_qq_ads/flutter_qq_ads.dart'; | ||
import 'package:loadany/loadany.dart'; | ||
|
||
import '../ads_config.dart'; | ||
import '../widgets/widgets.dart'; | ||
|
||
/// 信息流页面 | ||
class FeedPage extends StatefulWidget { | ||
FeedPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
_FeedPageState createState() => _FeedPageState(); | ||
} | ||
|
||
class _FeedPageState extends State<FeedPage> { | ||
List<int> feedList = []; | ||
List<int> feedAdList = []; | ||
|
||
LoadStatus loadStatus = LoadStatus.normal; | ||
|
||
@override | ||
void initState() { | ||
getFeedList(); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
clearFeedAd(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: buildAppBar(context, '信息流广告'), | ||
body: LoadAny( | ||
onLoadMore: () async { | ||
getFeedList(); | ||
}, | ||
status: loadStatus, | ||
child: CustomScrollView( | ||
slivers: [ | ||
SliverList( | ||
delegate: SliverChildBuilderDelegate( | ||
(BuildContext context, int index) { | ||
if (index % 5 == 4) { | ||
int adIndex = index ~/ 5; | ||
if (adIndex >= feedAdList.length) { | ||
return Container( | ||
height: 80, | ||
width: double.maxFinite, | ||
color: Colors.blueAccent, | ||
alignment: Alignment.centerLeft, | ||
child: Text('暂无广告 $index'), | ||
); | ||
} | ||
|
||
int adId = feedAdList[adIndex]; | ||
return AdFeedWidget( | ||
posId: '$adId', | ||
width: 375, | ||
height: 256, | ||
show: true, | ||
); | ||
} | ||
return LoadingItemWidget(); | ||
}, | ||
childCount: feedList.length, | ||
), | ||
) | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
/// 加载信息流 | ||
Future<void> getFeedList() async { | ||
setState(() { | ||
loadStatus = LoadStatus.loading; | ||
}); | ||
await Future.delayed(Duration(seconds: 2)); | ||
for (var i = 0; i < 30; i++) { | ||
feedList.add(i); | ||
} | ||
getFeedAdList(); | ||
} | ||
|
||
// 加载信息流广告 | ||
Future<void> getFeedAdList() async { | ||
try { | ||
List<int> adResultList = await FlutterQqAds.loadFeedAd( | ||
AdsConfig.feedId, | ||
count: 3, | ||
); | ||
feedAdList.addAll(adResultList); | ||
} catch (e) { | ||
print(e.toString()); | ||
} | ||
setState(() { | ||
loadStatus = LoadStatus.normal; | ||
}); | ||
} | ||
|
||
// 清除信息流广告 | ||
Future<void> clearFeedAd() async { | ||
bool result = await FlutterQqAds.clearFeedAd(feedAdList); | ||
print('clearFeedAd:$result'); | ||
} | ||
} | ||
|
||
/// 加载项组件 | ||
class LoadingItemWidget extends StatelessWidget { | ||
const LoadingItemWidget({ | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
height: 80, | ||
width: double.maxFinite, | ||
alignment: Alignment.centerLeft, | ||
padding: EdgeInsets.all(10), | ||
margin: EdgeInsets.symmetric(vertical: 10), | ||
color: Colors.white, | ||
child: Row( | ||
children: [ | ||
Container( | ||
width: 60, | ||
height: 60, | ||
decoration: BoxDecoration( | ||
shape: BoxShape.circle, | ||
color: Color(0xFFEBEBF4), | ||
), | ||
), | ||
SizedBox(width: 20), | ||
Expanded( | ||
child: Padding( | ||
padding: const EdgeInsets.all(4), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Container( | ||
width: double.maxFinite, | ||
height: 20, | ||
decoration: BoxDecoration( | ||
color: Color(0xFFEBEBF4), | ||
), | ||
), | ||
Spacer(), | ||
Container( | ||
width: 200, | ||
height: 20, | ||
decoration: BoxDecoration( | ||
color: Color(0xFFE4E4F4), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.