Skip to content

Commit

Permalink
Add getting started page
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Feb 28, 2024
1 parent 5f9d542 commit c4060ef
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 1 deletion.
73 changes: 73 additions & 0 deletions lib/getting_started_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:http/http.dart' as http;
import 'package:yaru_widgets/constants.dart';
import 'package:yaru_widgets/widgets.dart';

import 'build_context_x.dart';
import 'constants.dart';
import 'foot_note.dart';
import 'header_lead.dart';
import 'header_title.dart';
import 'message_fab.dart';
import 'scaffold_gradient.dart';
import 'top_menu_entry.dart';

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

@override
Widget build(BuildContext context) {
final width = context.mq.size.width;
return Container(
decoration: scaffoldGradient(context),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
title: const HeaderTitle(),
backgroundColor: Colors.transparent,
toolbarHeight: kToolBarHeight,
leadingWidth: kLeadingWidth,
leading: const HeaderLead(),
actions: createTopMenu(context),
),
body: Center(
child: FutureBuilder(
future: loadMarkdown(),
builder: (context, shot) {
if (!shot.hasData) {
return const Center(
child: YaruCircularProgressIndicator(),
);
}

return Markdown(
padding: EdgeInsets.symmetric(
vertical: kYaruPagePadding,
horizontal: width < 700 ? kYaruPagePadding : width * 0.2,
),
data: shot.data!,
);
},
),
),
bottomNavigationBar: const FootNote(),
floatingActionButton: const MessageFab(),
),
);
}
}

Future<String> loadMarkdown() async {
const address =
'https://raw.githubusercontent.com/ubuntu-flutter-community/yaru_tutorial/master/README.md';
final uri = Uri.parse(address);

final response = await http.get(uri);

if (response.statusCode == 200) {
return response.body;
} else {
throw 'Could not load';
}
}
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:github/github.dart';
import 'package:ubuntu_service/ubuntu_service.dart';
import 'constants.dart';
import 'contributor_service.dart';
import 'getting_started_page.dart';
import 'globals.dart';
import 'home_page.dart';
import 'contributors_page.dart';
Expand Down Expand Up @@ -46,6 +47,7 @@ class _MainAppState extends State<MainApp> {
'/': (context) => const HomePage(),
'/contributors': (context) => const ContributorsPage(),
'/projects': (context) => const ProjectsPage(),
'/gettingstarted': (context) => const GettingStartedPage(),
},
);
}
Expand Down
4 changes: 4 additions & 0 deletions lib/top_menu_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ List<Widget> createTopMenu(BuildContext context) => [
text: 'Contributors',
onPressed: () => Navigator.of(context).pushNamed('/contributors'),
),
TopMenuEntry(
text: 'Getting Started',
onPressed: () => Navigator.of(context).pushNamed('/gettingstarted'),
),
const SizedBox(
width: kYaruPagePadding,
),
Expand Down
26 changes: 25 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -86,6 +94,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
flutter_markdown:
dependency: "direct main"
description:
name: flutter_markdown
sha256: "5b24061317f850af858ef7151dadbb6eb77c1c449c954c7bb064e8a5e0e7d81f"
url: "https://pub.dev"
source: hosted
version: "0.6.20"
flutter_tabler_icons:
dependency: "direct main"
description:
Expand Down Expand Up @@ -137,7 +153,7 @@ packages:
source: hosted
version: "0.15.4"
http:
dependency: transitive
dependency: "direct main"
description:
name: http
sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba
Expand Down Expand Up @@ -168,6 +184,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
markdown:
dependency: transitive
description:
name: markdown
sha256: "1b134d9f8ff2da15cb298efe6cd8b7d2a78958c1b00384ebcbdf13fe340a6c90"
url: "https://pub.dev"
source: hosted
version: "7.2.1"
matcher:
dependency: transitive
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ dependencies:
flutter:
sdk: flutter

flutter_markdown: ^0.6.20
flutter_tabler_icons: ^1.21.0
github: ^9.23.0
http: ^1.2.0
path: ^1.8.3
shimmer: ^3.0.0
ubuntu_service: ^0.3.1
Expand Down

0 comments on commit c4060ef

Please sign in to comment.