Skip to content

Commit

Permalink
modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
Jawnnypoo committed Jan 23, 2024
1 parent a95990e commit f92423c
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 219 deletions.
41 changes: 30 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
name: Flutter build
name: Deploy to Pages

on:
push:
branches: [ main ]
branches: ["main"]

jobs:
build:
workflow_dispatch:

runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- name: Checkout
uses: actions/checkout@v4
- name: Build
uses: subosito/flutter-action@v2
with:
flutter-version: '3.0.0'
flutter-version: '3.16.7'
- run: flutter pub get
- run: flutter build web --base-href "/skyhook-web/"
- uses: JamesIves/[email protected]
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
branch: gh-pages
folder: build/web
path: 'build/web'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
15 changes: 0 additions & 15 deletions lib/data/storage_manager.dart

This file was deleted.

7 changes: 1 addition & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:skyhook/ui/theme_notifier.dart';
import 'skyhook_app.dart';

void main() {
runApp(ChangeNotifierProvider<ThemeNotifier>(
create: (_) => ThemeNotifier(),
child: const SkyhookApp(),
));
runApp(const SkyhookApp());
}
22 changes: 13 additions & 9 deletions lib/skyhook_app.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:skyhook/skyhook_home_page.dart';
import 'package:skyhook/ui/theme_notifier.dart';
import 'package:skyhook/ui/skyhook_colors.dart';

class SkyhookApp extends StatelessWidget {
const SkyhookApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Consumer<ThemeNotifier>(
builder: (context, themeNotifier, _) => MaterialApp(
title: 'skyhook',
debugShowCheckedModeBanner: false,
theme: themeNotifier.getTheme(),
home: SkyhookHomePage(title: 'skyhook', themeNotifier: themeNotifier,),
));
return MaterialApp(
title: 'SDPilates',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: SkyhookColors.primaryColor(),
brightness: Brightness.dark,
),
useMaterial3: true,
),
home: const SkyhookHomePage(title: 'skyhook'),
);
}
}
36 changes: 5 additions & 31 deletions lib/skyhook_home_page.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import 'package:flutter/material.dart';
import 'package:skyhook/ui/loading_widget_factory.dart';
import 'package:skyhook/model/provider.dart';
import 'package:flutter/services.dart';
import 'package:skyhook/api/skyhook_api.dart';
import 'package:skyhook/model/provider.dart';
import 'package:skyhook/ui/loading_widget_factory.dart';
import 'package:skyhook/ui/snackbar_helper.dart';
import 'package:skyhook/ui/theme_notifier.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/services.dart';

class SkyhookHomePage extends StatefulWidget {
const SkyhookHomePage(
{Key? key, required this.title, required this.themeNotifier})
: super(key: key);
const SkyhookHomePage({Key? key, required this.title}) : super(key: key);

final String title;
final ThemeNotifier themeNotifier;

@override
State<SkyhookHomePage> createState() => _SkyhookHomePageState();
Expand All @@ -23,21 +19,14 @@ class _SkyhookHomePageState extends State<SkyhookHomePage> {
List<Provider> _providers = List.empty();
Provider? _selectedProvider;
String? _currentErrorMessage;
late IconData _iconData;
late TextEditingController _controller;

@override
void initState() {
super.initState();
_controller = TextEditingController();
_controller.addListener(_onTyped);
widget.themeNotifier.addListener(_setFromNotifier);
_loadProviders();
if (widget.themeNotifier.isDarkTheme()) {
_iconData = Icons.light_mode;
} else {
_iconData = Icons.dark_mode;
}
}

@override
Expand Down Expand Up @@ -121,29 +110,13 @@ class _SkyhookHomePageState extends State<SkyhookHomePage> {
.catchError(_onError);
}

void _setFromNotifier() {
setState(() {
if (widget.themeNotifier.isDarkTheme()) {
_iconData = Icons.light_mode;
} else {
_iconData = Icons.dark_mode;
}
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
centerTitle: false,
actions: [
IconButton(
icon: Icon(_iconData),
onPressed: () {
widget.themeNotifier.toggle();
},
),
IconButton(
icon: const Icon(Icons.code),
onPressed: () {
Expand All @@ -159,6 +132,7 @@ class _SkyhookHomePageState extends State<SkyhookHomePage> {
],
),
body: Card(
color: Colors.black,
margin: const EdgeInsets.all(20.0),
child: ListView(
padding: const EdgeInsets.all(40.0),
Expand Down
48 changes: 0 additions & 48 deletions lib/ui/theme_notifier.dart

This file was deleted.

Loading

0 comments on commit f92423c

Please sign in to comment.