This commit is contained in:
2020-12-28 00:19:04 -05:00
parent 86c845b49b
commit c378a6203c
33 changed files with 833 additions and 200 deletions

View File

@@ -38,7 +38,7 @@ class BottomNavState extends State<BottomNav> {
child: Text(
'All logos shown are registered trademark, copyrighted and belong to their respective owners.',
style: TextStyle(
fontSize: 10.0,
fontSize: 8.0,
color: Colors.white60,
),
),

View File

@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import '../../utils/http_util.dart';
import '../../widgets/desktop/desktop_download_apps.dart';
import '../../widgets/mobile/mobile_download_apps.dart';
import 'package:responsive_builder/responsive_builder.dart';
class DownloadApps extends StatefulWidget {
const DownloadApps({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return DownloadAppsState();
}
}
class DownloadAppsState extends State<DownloadApps> {
Map<String, dynamic> data;
@override
Widget build(BuildContext context) {
return ScreenTypeLayout(
mobile: MobileDownloadApps(data),
tablet: DesktopDownloadApps(data),
desktop: DesktopDownloadApps(data),
);
}
@override
void initState() {
super.initState();
_loadData();
}
void _loadData() {
HttpUtil.httpGet('v1/get-wisetronic-download-page')
.then((value) {
print('$value');
if (mounted) {
setState(() {
data = value;
});
}
});
}
}

View File

@@ -1,6 +1,14 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../widgets/general/text_link.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../generated/l10n.dart';
import '../../utils/utils.dart';
import '../../utils/extensions.dart';
import 'package:universal_io/io.dart';
import '../../constants.dart';
import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dart';
class DownloadItem extends StatefulWidget {
@@ -16,15 +24,20 @@ class DownloadItem extends StatefulWidget {
}
class DownloadItemState extends State<DownloadItem> {
final double buttonWidth = 114.0;
final double iconWidth = 48.0;
@override
Widget build(BuildContext context) {
return Container(
width: widget.width ?? MediaQuery.of(context).size.width,
padding: EdgeInsets.only(top: 10.0, bottom: 10.0, left: 10.0, right: 10.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -32,15 +45,26 @@ class DownloadItemState extends State<DownloadItem> {
child: Row(
children: [
Container(
child: Util.showImage(
'https:${widget.desc['app_icon']}',
width: 32.0,
height: 32.0,
fit: BoxFit.fill,
child: (kIsWeb) ?
Image.network(
'${widget.desc['app_icon']}',
) :
SvgPicture.network(
'${widget.desc['app_icon']}',
placeholderBuilder: (BuildContext context) => Container(
padding: const EdgeInsets.all(30.0),
child: const CircularProgressIndicator(),
),
),
width: iconWidth,
height: iconWidth,
margin: EdgeInsets.only(right: 16.0),
),
Container(
width: widget.width != null ? widget.width - iconWidth - buttonWidth - 60 : MediaQuery.of(context).size.width - iconWidth - buttonWidth - 60,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'${widget.desc['name']}',
@@ -49,6 +73,8 @@ class DownloadItemState extends State<DownloadItem> {
fontSize: 15.0,
color: Colors.black87,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
Text(
'${widget.desc['version']}',
@@ -57,6 +83,7 @@ class DownloadItemState extends State<DownloadItem> {
color: Colors.black38,
),
),
getSupportedOSs(),
],
),
),
@@ -64,18 +91,19 @@ class DownloadItemState extends State<DownloadItem> {
),
),
Container(
width: buttonWidth,
child: getDownloadButton(),
),
],
),
),
Container(
padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0),
child: Text(
'${widget.desc['description']}',
style: TextStyle(
color: Colors.black54,
),
overflow: TextOverflow.ellipsis,
),
),
],
@@ -83,8 +111,222 @@ class DownloadItemState extends State<DownloadItem> {
);
}
Widget getDownloadButton() {
Widget getSupportedOSs() {
Row row = Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [],
);
for (int i = 0; i < (widget.desc['urls'] as List).length; i++) {
switch((widget.desc['urls'] as List)[i]['os']) {
case 'windows':
row.children.add(Container(
margin: EdgeInsets.all(3.0),
child: Icon(
IconData(
Constants.FONT_WINDOWS,
fontFamily: 'wisetronic',
fontPackage: null
),
color: Colors.green,
size: 20.0,
),
));
break;
case 'mac':
row.children.add(Container(
margin: EdgeInsets.all(3.0),
child: Icon(
IconData(
Constants.FONT_APPLE,
fontFamily: 'wisetronic',
fontPackage: null
),
color: Colors.green,
size: 20.0,
),
));
break;
case 'ubuntu':
row.children.add(Container(
margin: EdgeInsets.all(3.0),
child: Icon(
IconData(
Constants.FONT_UBUNTU,
fontFamily: 'wisetronic',
fontPackage: null
),
color: Colors.green,
size: 20.0,
),
));
break;
case 'android':
row.children.add(Container(
margin: EdgeInsets.all(3.0),
child: Icon(
IconData(
Constants.FONT_ANDROID,
fontFamily: 'wisetronic',
fontPackage: null
),
color: Colors.green,
size: 20.0,
),
));
break;
case 'ios':
row.children.add(Container(
margin: EdgeInsets.all(3.0),
child: Icon(
IconData(
Constants.FONT_IOS,
fontFamily: 'wisetronic',
fontPackage: null
),
color: Colors.green,
size: 20.0,
),
));
break;
}
}
return row;
}
return null;
Widget getDownloadButton() {
String downloadUrl;
String os = Utils.getOs();
String selectedOs;
List<String> supportedOss = [];
for (int i = 0; i < (widget.desc['urls'] as List).length; i++) {
supportedOss.add((widget.desc['urls'] as List)[i]['os']);
if ((widget.desc['urls'] as List)[i]['url'] == 'instore') {
downloadUrl = 'instore';
}
if ((widget.desc['urls'] as List)[i]['os'] == os) {
selectedOs = (widget.desc['urls'] as List)[i]['os'];
downloadUrl = (widget.desc['urls'] as List)[i]['url'];
break;
}
}
print('download url $downloadUrl');
if (downloadUrl != null && downloadUrl == 'instore') {
return Container(
padding: EdgeInsets.all(8.0),
child: Text(
S.of(context).install_in_store,
style: TextStyle(
color: Colors.black54,
fontSize: 11.5,
),
textAlign: TextAlign.center,
),
decoration: BoxDecoration(
// color: Colors.black54,
border: Border(
top: BorderSide(
width: 0.5,
color: Colors.black54,
),
bottom: BorderSide(
width: 0.5,
color: Colors.black54,
),
left: BorderSide(
width: 0.5,
color: Colors.black54,
),
right: BorderSide(
width: 0.5,
color: Colors.black54,
),
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5.0),
topRight: Radius.circular(5.0),
bottomLeft: Radius.circular(5.0),
bottomRight: Radius.circular(5.0),
),
),
);
} else if (downloadUrl != null && downloadUrl.isNotEmpty) {
return RaisedButton(
color: Theme.of(context).primaryColor,
padding: EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.only(right: 0.0, left: 6.0, top: 6.0, bottom: 6.0),
child: Icon(
IconData(
Utils.getOsFontHex(selectedOs),
fontFamily: 'wisetronic',
fontPackage: null
),
color: Colors.white,
size: 18.0,
),
),
Container(
padding: EdgeInsets.all(6.0),
child: Text(
S.of(context).download,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
],
),
onPressed: () async {
if (await canLaunch(downloadUrl)) {
await launch('$downloadUrl');
}
},
);
} else {
return Container(
padding: EdgeInsets.all(8.0),
child: Text(
S.of(context).download_with_token(supportedOss.join(', ').eachFirstCap),
style: TextStyle(
color: Colors.black54,
fontSize: 11.5,
),
textAlign: TextAlign.center,
),
decoration: BoxDecoration(
// color: Colors.black54,
border: Border(
top: BorderSide(
width: 0.5,
color: Colors.black54,
),
bottom: BorderSide(
width: 0.5,
color: Colors.black54,
),
left: BorderSide(
width: 0.5,
color: Colors.black54,
),
right: BorderSide(
width: 0.5,
color: Colors.black54,
),
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5.0),
topRight: Radius.circular(5.0),
bottomLeft: Radius.circular(5.0),
bottomRight: Radius.circular(5.0),
),
),
);
}
}
}

View File

@@ -7,11 +7,15 @@ import 'package:responsive_builder/responsive_builder.dart';
class NavigationBar extends StatefulWidget implements PreferredSizeWidget {
final Key key;
final PreferredSizeWidget bottom;
final String title;
final bool back;
NavigationBar({Key key, PreferredSizeWidget bottom})
NavigationBar({Key key, PreferredSizeWidget bottom, String title, bool back})
: key = key,
preferredSize = Size.fromHeight(kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)),
bottom = bottom;
bottom = bottom,
title = title ?? '',
back = back ?? false;
@override
final Size preferredSize;
@@ -28,7 +32,7 @@ class NavigationBarState extends State<NavigationBar> {
@override
Widget build(BuildContext context) {
return ScreenTypeLayout(
mobile: MobileNavigationBar(),
mobile: MobileNavigationBar(title: widget.title, back: widget.back,),
tablet: DesktopNavigationBar(),
desktop: DesktopNavigationBar(),
);

View File

@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import '../../constants.dart';
class NavigationBarLogo extends StatelessWidget {
const NavigationBarLogo({Key key}) : super(key: key);
static const IconData logoData = IconData(
0xe800,
Constants.FONT_WISETRONIC,
fontFamily: 'wisetronic',
fontPackage: null
);

View File

@@ -1,8 +1,11 @@
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../routes.dart';
class TextLink extends StatelessWidget {
final String title;
final String url;
@@ -11,13 +14,33 @@ class TextLink extends StatelessWidget {
final double paddingVertical;
final FontWeight fontWeight;
final bool selected;
final bool isLink;
final bool replace;
final bool clearStack;
final bool maintainState;
final bool rootNavigator;
final TransitionType transition;
final bool closeDrawer;
TextLink(this.title, this.url, {
this.color,
this.paddingHorizontal,
this.paddingVertical,
this.fontWeight,
this.selected
});
this.selected,
bool isLink,
bool replace,
bool clearStack,
bool maintainState,
bool rootNavigator,
this.transition,
bool closeDrawer,
}) :
isLink = isLink ?? false,
replace = replace ?? false,
clearStack = clearStack ?? false,
maintainState = maintainState ?? true,
rootNavigator = rootNavigator ?? false,
closeDrawer = closeDrawer ?? false;
@override
Widget build(BuildContext context) {
@@ -46,10 +69,23 @@ class TextLink extends StatelessWidget {
),
),
onTap: () async {
if (await canLaunch(url)) {
await launch(url);
if (!isLink) {
if (closeDrawer) {
Routes.router.pop(context);
}
Routes.router.navigateTo(
context, url,
replace: replace,
clearStack: clearStack,
maintainState: maintainState,
rootNavigator: rootNavigator,
);
} else {
throw 'Could not launch $url';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
},
),