Skip to content

Commit

Permalink
🚀 Enhanced App Info Screen!
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaui committed Mar 31, 2023
1 parent 95bbfe4 commit 873051a
Showing 1 changed file with 97 additions and 1 deletion.
98 changes: 97 additions & 1 deletion lib/ui/screens/app_info_screen.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import 'dart:convert';

import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:chat_desk/io/app_style.dart';
import 'package:chat_desk/ui/utils.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:url_launcher/url_launcher_string.dart';

class AppInfoScreen extends StatelessWidget {
const AppInfoScreen({super.key});

Future<int> _fetchStars() async {
var request = await http
.get(Uri.parse('https://api.github.com/repos/omegaui/chat_desk'));
if (request.statusCode == 200) {
var body = request.body;
var json = jsonDecode(body);
return json['stargazers_count'];
}
return -1;
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -94,7 +109,88 @@ class AppInfoScreen extends StatelessWidget {
alignment: Alignment.topRight,
child: Padding(
padding: const EdgeInsets.all(40.0),
child: Container(),
child: GestureDetector(
onTap: () async {
var url = "https://github.com/omegaui/chat_desk";
if (await canLaunchUrlString(url)) {
await launchUrlString(url);
}
},
child: AppUtils.buildTooltip(
text: "Visit Repo",
child: Container(
width: 200,
height: 60,
decoration: BoxDecoration(
color: currentStyleMode == AppStyle.light
? const Color(0xffc0c0c0).withOpacity(0.25)
: Colors.black.withOpacity(0.1),
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: FutureBuilder(
future: _fetchStars(),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Text(
"Fetching data ...",
style: TextStyle(
fontFamily: "Sen",
color: currentStyle.getTextColor(),
),
);
}
if (snapshot.hasError || snapshot.data == -1) {
return Text(
"Cannot fetch Stars",
style: TextStyle(
fontFamily: "Sen",
color: currentStyle.getTextColor(),
),
);
}
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${snapshot.data} Stars",
style: TextStyle(
fontFamily: "Sen",
fontSize: 22,
color: currentStyle.getTextColor(),
),
),
Icon(
Icons.star,
color: Colors.yellow.shade800,
size: 22,
),
const SizedBox(width: 10),
Text(
"on",
style: TextStyle(
fontFamily: "Sen",
fontSize: 22,
color: currentStyle.getTextColor(),
),
),
const SizedBox(width: 10),
Image.asset(
'assets/icon/icons8-github-96.png',
width: 32,
),
],
),
);
},
),
),
),
),
),
),
),
Align(
Expand Down

0 comments on commit 873051a

Please sign in to comment.