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

Staging Tentacool #239

Merged
merged 6 commits into from
Oct 17, 2024
Merged
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
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 33
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
4 changes: 4 additions & 0 deletions lib/core/route/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,9 @@ class AppRoute {
static const communitNotificationSerttings = 'communitNotificationSerttings';
static const communitNotificationSerttingsRoute = '/communitNotificationSerttings';

static const adsList = 'adsList';
static const adsListRoute = '/adsList';

static const adsSettings = 'adsSettings';
static const adsSettingsRoute = '/adsSettings';
}
18 changes: 18 additions & 0 deletions lib/core/route/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'dart:developer';
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter_social_sample_app/core/preferences/preference_interface_impl.dart';
import 'package:flutter_social_sample_app/core/route/app_route.dart';
import 'package:flutter_social_sample_app/presentation/screen/ads/ads_list_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/ads/ads_settings_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/channel_create/channel_create_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/channel_list/channel_list_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/channel_profile/channel_profile_screen.dart';
Expand Down Expand Up @@ -497,6 +499,22 @@ class AppRouter {
return const UserBlockedListScreen();
},
),

GoRoute(
name: AppRoute.adsList,
path: AppRoute.adsListRoute,
builder: (context, state) {
return const AdsListScreen();
},
),

GoRoute(
name: AppRoute.adsSettings,
path: AppRoute.adsSettingsRoute,
builder: (context, state) {
return const AdsSettingsScreen();
},
),
],
redirect: (context, state) async {
if (state.location == AppRoute.loginRoute) {
Expand Down
100 changes: 100 additions & 0 deletions lib/core/widget/ad_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_social_sample_app/core/widget/advertiser_row_widget.dart';
import 'package:url_launcher/url_launcher.dart';

class AdWidget extends StatelessWidget {
final AmityAd amityAd;

const AdWidget({Key? key, required this.amityAd}) : super(key: key);

@override
Widget build(BuildContext context) {
final themeData = Theme.of(context);
return Container(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
AdvertiserRowWidget(
advertiserId: amityAd.advertiserId ?? '',
companyName: amityAd.advertiser?.companyName,
advertiserAvatar: amityAd.advertiser?.avatar),
Text(
'Ad id - ${amityAd.adId}',
style: themeData.textTheme.bodySmall,
),
Text(
'Target - ${amityAd.adTarget}',
style: themeData.textTheme.bodySmall,
),
Text(
'Placements - ${amityAd.placements}',
style: themeData.textTheme.bodySmall,
),
Text(
'Start at - ${amityAd.startAt ?? 'N/A'}',
style: themeData.textTheme.bodySmall,
),
Text(
'End at - ${amityAd.endAt ?? 'forever'}',
style: themeData.textTheme.bodySmall,
),
Text(
'Name - ${amityAd.name}',
style: themeData.textTheme.titleMedium,
),
Text(
'Headline - ${amityAd.headline ?? 'N/A - Headline is not available'}',
style: themeData.textTheme.titleLarge,
),
Text(
'Description - ${amityAd.description ?? 'N/A - Description is not available'}',
style: themeData.textTheme.bodyMedium,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Container(
margin: const EdgeInsets.all(4),
color: Colors.blueGrey.withOpacity(.25),
width: 130,
height: 130,
child: (amityAd.image1_1 != null)
? Image.network(
amityAd.image1_1!.getUrl(AmityImageSize.MEDIUM),
fit: BoxFit.cover,
)
: const Align(
alignment: Alignment.center,
child: Text(
"1:1 Ad image is not available",
textAlign: TextAlign.center,
),
),
),
Container(
margin: const EdgeInsets.all(4),
color: Colors.blueGrey.withOpacity(.25),
width: 130,
height: 130,
child: (amityAd.image9_16 != null)
? Image.network(
amityAd.image9_16!.getUrl(AmityImageSize.MEDIUM),
fit: BoxFit.fitWidth,
)
: const Align(
alignment: Alignment.center,
child: Text(
"9:16 Ad image is not available",
textAlign: TextAlign.center,
),
))
]),
],
),
);
}
}
68 changes: 68 additions & 0 deletions lib/core/widget/advertiser_row_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter/material.dart';

class AdvertiserRowWidget extends StatelessWidget {
const AdvertiserRowWidget(
{Key? key,
required this.advertiserId,
this.companyName,
this.advertiserAvatar})
: super(key: key);

final String advertiserId;
final AmityImage? advertiserAvatar;
final String? companyName;

@override
Widget build(BuildContext context) {
final themeData = Theme.of(context);
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey.withOpacity(
.3,
),
),
clipBehavior: Clip.antiAliasWithSaveLayer,
child: advertiserAvatar != null
? Image.network(
advertiserAvatar!.getUrl(AmityImageSize.MEDIUM),
fit: BoxFit.fill,
)
: Image.asset('assets/user_placeholder.png'),
),
const SizedBox(width: 18),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
companyName ?? 'company name is not available',
style: themeData.textTheme.titleLarge,
),
Text(
'advertiserId: $advertiserId',
style: themeData.textTheme.bodySmall,
),
],
),
),
const Spacer()
],
),
);
}
}
63 changes: 63 additions & 0 deletions lib/presentation/screen/ads/ads_list_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_social_sample_app/core/widget/ad_widget.dart';

class AdsListScreen extends StatefulWidget {
const AdsListScreen({Key? key}) : super(key: key);
@override
State<AdsListScreen> createState() => _AdsListScreenState();
}

final ScrollController scrollController = ScrollController();

class _AdsListScreenState extends State<AdsListScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Ads List 👩‍🚀'),
),
body: Container(
width: double.maxFinite,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.black26,
width: 1,
),
),
child: Column(
children: [
Expanded(
child: FutureBuilder<AmityNetworkAds>(
future: AmityCoreClient.newAdRepository().getNetworkAds(),
builder: (context, snapshot) {
if (snapshot.hasData &&
(snapshot.data?.ads?.isNotEmpty ?? false)) {
List<AmityAd> networkAds = snapshot.data!.ads!;
return ListView.builder(
controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(),
itemCount: networkAds.length,
itemBuilder: (context, index) {
final networkAd = networkAds[index];
return AdWidget(key: UniqueKey(), amityAd: networkAd);
});
} else if (snapshot.hasError) {
return Center(
child: Text(snapshot.error.toString()),
);
} else {
return const Center(
child: CircularProgressIndicator(),
);
}
},
),
),
],
),
),
);
}
}
83 changes: 83 additions & 0 deletions lib/presentation/screen/ads/ads_settings_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter/material.dart';

class AdsSettingsScreen extends StatefulWidget {
const AdsSettingsScreen({Key? key}) : super(key: key);
@override
State<AdsSettingsScreen> createState() => _AdsSettingsScreenState();
}

final ScrollController scrollController = ScrollController();

class _AdsSettingsScreenState extends State<AdsSettingsScreen> {
@override
Widget build(BuildContext context) {
final themeData = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: const Text('Ads Settings ⚙️'),
),
body: Container(
width: double.maxFinite,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.black26,
width: 1,
),
),
child: Column(
children: [
Expanded(
child: FutureBuilder<AmityNetworkAds>(
future: AmityCoreClient.newAdRepository().getNetworkAds(),
builder: (context, snapshot) {
if (snapshot.hasData && (snapshot.data?.settings != null)) {
AmityAdsSettings settings = snapshot.data!.settings!;
return Expanded(
child: Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Is enabled - ${settings.isEnabled ?? 'N/A'}',
style: themeData.textTheme.bodyMedium,
),
Text(
'Max active - ${settings.maxActiveAds ?? 'N/A'}',
style: themeData.textTheme.bodyMedium,
),
Text(
'Feed frequency- ${settings.getFrequency()?.getFeedAdFrequency().type ?? 'N/A'} ${settings.getFrequency()?.getFeedAdFrequency().value ?? 'N/A'}',
style: themeData.textTheme.bodyMedium,
),
Text(
'Story frequency- ${settings.getFrequency()?.getStoryAdFrequency().type ?? 'N/A'} ${settings.getFrequency()?.getStoryAdFrequency().value ?? 'N/A'}',
style: themeData.textTheme.bodyMedium,
),
Text(
'Comment frequency- ${settings.getFrequency()?.getCommentAdFrequency().type ?? 'N/A'} ${settings.getFrequency()?.getCommentAdFrequency().value ?? 'N/A'}',
style: themeData.textTheme.bodyMedium,
),
],
),
));
} else if (snapshot.hasError) {
return Center(
child: Text(snapshot.error.toString()),
);
} else {
return const Center(
child: CircularProgressIndicator(),
);
}
},
),
),
],
),
),
);
}
}
Loading
Loading