forked from firka/student-legacy
ads api working
This commit is contained in:
parent
b6eb65814f
commit
2cba1ec286
@ -19,8 +19,8 @@ class FilcAPI {
|
|||||||
static const supporters = "https://api.refilc.hu/v1/public/supporters";
|
static const supporters = "https://api.refilc.hu/v1/public/supporters";
|
||||||
|
|
||||||
// Private API
|
// Private API
|
||||||
static const config = "https://api.refilc.hu/v1/private/config";
|
|
||||||
static const ads = "https://api.refilc.hu/v1/private/ads";
|
static const ads = "https://api.refilc.hu/v1/private/ads";
|
||||||
|
static const config = "https://api.refilc.hu/v1/private/config";
|
||||||
static const reportApi = "https://api.refilc.hu/v1/private/crash-report";
|
static const reportApi = "https://api.refilc.hu/v1/private/crash-report";
|
||||||
static const premiumApi = "https://api.filcnaplo.hu/premium/activate";
|
static const premiumApi = "https://api.filcnaplo.hu/premium/activate";
|
||||||
// static const premiumScopesApi = "https://api.filcnaplo.hu/premium/scopes";
|
// static const premiumScopesApi = "https://api.filcnaplo.hu/premium/scopes";
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:math';
|
|||||||
|
|
||||||
import 'package:dynamic_color/dynamic_color.dart';
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
import 'package:filcnaplo/api/client.dart';
|
import 'package:filcnaplo/api/client.dart';
|
||||||
|
import 'package:filcnaplo/api/providers/ad_provider.dart';
|
||||||
import 'package:filcnaplo/api/providers/live_card_provider.dart';
|
import 'package:filcnaplo/api/providers/live_card_provider.dart';
|
||||||
import 'package:filcnaplo/api/providers/news_provider.dart';
|
import 'package:filcnaplo/api/providers/news_provider.dart';
|
||||||
import 'package:filcnaplo/api/providers/database_provider.dart';
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
@ -104,6 +105,8 @@ class App extends StatelessWidget {
|
|||||||
create: (context) => NewsProvider(context: context)),
|
create: (context) => NewsProvider(context: context)),
|
||||||
ChangeNotifierProvider<UpdateProvider>(
|
ChangeNotifierProvider<UpdateProvider>(
|
||||||
create: (context) => UpdateProvider(context: context)),
|
create: (context) => UpdateProvider(context: context)),
|
||||||
|
ChangeNotifierProvider<AdProvider>(
|
||||||
|
create: (context) => AdProvider(context: context)),
|
||||||
|
|
||||||
// user data (kreten) providers
|
// user data (kreten) providers
|
||||||
ChangeNotifierProvider<GradeProvider>(
|
ChangeNotifierProvider<GradeProvider>(
|
||||||
|
@ -5,14 +5,16 @@ class Ad {
|
|||||||
Uri? logoUrl;
|
Uri? logoUrl;
|
||||||
bool overridePremium;
|
bool overridePremium;
|
||||||
DateTime date;
|
DateTime date;
|
||||||
|
Uri launchUrl;
|
||||||
|
|
||||||
Ad({
|
Ad({
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.description,
|
required this.description,
|
||||||
required this.author,
|
required this.author,
|
||||||
required this.logoUrl,
|
this.logoUrl,
|
||||||
this.overridePremium = false,
|
this.overridePremium = false,
|
||||||
required this.date,
|
required this.date,
|
||||||
|
required this.launchUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Ad.fromJson(Map json) {
|
factory Ad.fromJson(Map json) {
|
||||||
@ -24,6 +26,7 @@ class Ad {
|
|||||||
overridePremium: json['override_premium'] ?? false,
|
overridePremium: json['override_premium'] ?? false,
|
||||||
date:
|
date:
|
||||||
json['date'] != null ? DateTime.parse(json['date']) : DateTime.now(),
|
json['date'] != null ? DateTime.parse(json['date']) : DateTime.now(),
|
||||||
|
launchUrl: Uri.parse(json['launch_url'] ?? 'https://refilc.hu'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:filcnaplo/models/ad.dart';
|
import 'package:filcnaplo/models/ad.dart';
|
||||||
|
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/common/panel/panel_button.dart';
|
import 'package:filcnaplo_mobile_ui/common/panel/panel_button.dart';
|
||||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
@ -17,12 +18,30 @@ class AdTile extends StatelessWidget {
|
|||||||
child: PanelButton(
|
child: PanelButton(
|
||||||
onPressed: onTap,
|
onPressed: onTap,
|
||||||
title: Column(
|
title: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(ad.title),
|
Text(
|
||||||
Text(ad.description),
|
ad.title,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
ad.description,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: AppColors.of(context).text.withOpacity(0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
leading: Image.network(ad.logoUrl.toString()),
|
leading: ad.logoUrl != null
|
||||||
|
? Image.network(
|
||||||
|
ad.logoUrl.toString(),
|
||||||
|
errorBuilder: (context, error, stackTrace) {
|
||||||
|
ad.logoUrl = null;
|
||||||
|
return const SizedBox();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
trailing: const Icon(FeatherIcons.externalLink),
|
trailing: const Icon(FeatherIcons.externalLink),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:filcnaplo/models/ad.dart';
|
import 'package:filcnaplo/models/ad.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import 'ad_tile.dart';
|
import 'ad_tile.dart';
|
||||||
|
|
||||||
@ -12,7 +13,10 @@ class AdViewable extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AdTile(
|
return AdTile(
|
||||||
ad,
|
ad,
|
||||||
onTap: () => [],
|
onTap: () => launchUrl(
|
||||||
|
ad.launchUrl,
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user