Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CLASHBOT_SERVICE_URL=CLASHBOT_SERVICE_URL
MOCK_DISCORD_SERVICE=MOCK_DISCORD_SERVICE
CLASHBOT_SERVICE_URL=http://localhost:8080
MOCK_DISCORD_SERVICE=false
discordClientId=1234567890
27 changes: 21 additions & 6 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ jobs:
- name: Download Dependencies
run: flutter pub get

- name: Create environment file
- name: Create environment file
env:
CLASHBOT_SERVICE_URL: http://localhost:8080/api/v2
MOCK_DISCORD_SERVICE: false
run: ./ciScripts/build-env-file.sh CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE}
DISCORD_CLIENT_ID: 1234567
run: |
./ciScripts/build-env-file.sh \
CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} \
MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} \
discordClientId ${DISCORD_CLIENT_ID}

- name: Unit Tests
run: flutter test "test/unit/" >> $GITHUB_STEP_SUMMARY
Expand All @@ -59,11 +64,16 @@ jobs:
- name: Download Dependencies
run: flutter pub get

- name: Create environment file
- name: Create environment file
env:
CLASHBOT_SERVICE_URL: http://localhost:8080/api/v2
MOCK_DISCORD_SERVICE: false
run: ./ciScripts/build-env-file.sh CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE}
DISCORD_CLIENT_ID: 123456
run: |
./ciScripts/build-env-file.sh \
CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} \
MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} \
discordClientId ${DISCORD_CLIENT_ID}

- name: Generate Envied Files
run: flutter pub run build_runner build --delete-conflicting-outputs
Expand Down Expand Up @@ -100,11 +110,16 @@ jobs:
- name: Check Flutter version
run: flutter --version

- name: Create environment file
- name: Create environment file
env:
CLASHBOT_SERVICE_URL: http://localhost:8080/api/v2
MOCK_DISCORD_SERVICE: false
run: ./ciScripts/build-env-file.sh CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE}
DISCORD_CLIENT_ID: 1234567
run: |
./ciScripts/build-env-file.sh \
CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} \
MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} \
discordClientId ${DISCORD_CLIENT_ID}

- name: Generate Envied Files
run: flutter pub run build_runner build --delete-conflicting-outputs
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
env:
CLASHBOT_SERVICE_URL: ${{ vars.CLASHBOT_SERVICE_URL }}
MOCK_DISCORD_SERVICE: false
run: ./ciScripts/build-env-file.sh CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE}
DISCORD_CLIENT_ID: ${{ vars.DISCORD_CLIENT_ID }}
run: ./ciScripts/build-env-file.sh CLASHBOT_SERVICE_URL ${CLASHBOT_SERVICE_URL} MOCK_DISCORD_SERVICE ${MOCK_DISCORD_SERVICE} discordClientId ${DISCORD_CLIENT_ID}

- name: Generate Envied Files
run: |
Expand Down
2 changes: 2 additions & 0 deletions lib/core/config/env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ abstract class Env {
static String clashbotServiceUrl = _Env.clashbotServiceUrl;
@EnviedField(varName: 'MOCK_DISCORD_SERVICE')
static String mockDiscordService = _Env.mockDiscordService;
@EnviedField()
static String discordClientId = _Env.discordClientId;
}
2 changes: 0 additions & 2 deletions lib/globals/credentials.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'dart:io';

abstract class Credentials {
static const APP_DISCORD_OAUTH_CLIENT_ID = "837629412328734740";
// static const APP_DISCORD_OAUTH_CLIENT_ID = "839586949748228156";
static const APP_DISCORD_OAUTH_REDIRECT_URI = "http://localhost:4200/login";
static const SCOPE = ['identify', 'guilds'];
static final appUserCredentialsFile = new File("~/.myapp/credentials.json");
Expand Down
3 changes: 2 additions & 1 deletion lib/globals/global_settings.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:clashbot_flutter/clients/discord_client.dart';
import 'package:clashbot_flutter/core/config/env.dart';
import 'package:clashbot_flutter/globals/credentials.dart';
import 'package:oauth2_client/oauth2_helper.dart';

Expand Down Expand Up @@ -39,7 +40,7 @@ OAuth2Helper setupOauth2Helper() {
var oAuth2Helper = OAuth2Helper(
client,
grantType: OAuth2Helper.authorizationCode,
clientId: Credentials.APP_DISCORD_OAUTH_CLIENT_ID,
clientId: Env.discordClientId,
scopes: Credentials.SCOPE,
);
return oAuth2Helper;
Expand Down
54 changes: 29 additions & 25 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import 'dart:developer' as developer;

import 'package:clash_bot_api/api.dart';
import 'package:clashbot_flutter/core/config/env.dart';
import 'package:clashbot_flutter/globals/color_schemes.dart';
import 'package:clashbot_flutter/models/clash_team.dart';
import 'package:clashbot_flutter/models/model_first_time.dart';
import 'package:clashbot_flutter/pages/errorPages/whoops_page.dart';
import 'package:clashbot_flutter/pages/home/page/home_v2.dart';
import 'package:clashbot_flutter/pages/home/page/widgets/team_card.dart';
import 'package:clashbot_flutter/pages/intro/welcome_page.dart';
import 'package:clashbot_flutter/routes.dart';
import 'package:clashbot_flutter/services/clashbot_service.dart';
import 'package:clashbot_flutter/services/clashbot_service_impl.dart';
import 'package:clashbot_flutter/services/discord_service.dart';
import 'package:clashbot_flutter/services/discord_service_impl.dart';
import 'package:clashbot_flutter/services/discord_service_mock_impl.dart';
import 'package:clashbot_flutter/services/riot_resources_service.dart';
import 'package:clashbot_flutter/services/riot_resources_service_impl.dart';
import 'package:clashbot_flutter/stores/application_details.store.dart';
Expand All @@ -30,8 +26,8 @@ import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:mobx/mobx.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:validators/validators.dart';
import 'package:storybook_flutter/storybook_flutter.dart';

import 'generated/git_info.dart';
import 'globals/global_settings.dart';
Expand Down Expand Up @@ -73,17 +69,23 @@ GoRouter router = GoRouter(
builder: (BuildContext context, GoRouterState state) {
return HomeV2();
}),
GoRoute(
name: 'whoops',
path: WHOOPS_ROUTE,
builder: (BuildContext context, GoRouterState state) {
return const WhoopsPage();
}),
]),
],
errorBuilder: (context, state) => Scaffold(
errorBuilder: (context, state) => const Scaffold(
body: Center(
child: Column(
children: const [
children: [
Text('Page Not Found', style: headerStyle),
],
),
)),
debugLogDiagnostics: true);
debugLogDiagnostics: false);

void main() async {
runApp(MyApp());
Expand Down Expand Up @@ -118,23 +120,25 @@ class _MyAppState extends State<MyApp> {
providers: [
ChangeNotifierProvider(create: (context) => widget.modelFirstTime),
ChangeNotifierProvider(create: (context) => widget.modelTheme),
Provider<ErrorHandlerStore>(create: (_) => ErrorHandlerStore()),
Provider<DiscordService>(
create: (_) => DiscordServiceImpl(setupOauth2Helper())),
Provider<ApiClient>(
create: (_) => ApiClient(basePath: Env.clashbotServiceUrl)),
ProxyProvider<ApiClient, ClashBotService>(
update: (_, apiClient, __) => ClashBotServiceImpl(
UserApi(apiClient),
TeamApi(apiClient),
ChampionsApi(apiClient),
SubscriptionApi(apiClient),
TentativeApi(apiClient),
TournamentApi(apiClient))),
ProxyProvider2<ApiClient, ErrorHandlerStore, ClashBotService>(
update: (_, apiClient, errorHandlerStore, __) =>
ClashBotServiceImpl(
UserApi(apiClient),
TeamApi(apiClient),
ChampionsApi(apiClient),
SubscriptionApi(apiClient),
TentativeApi(apiClient),
TournamentApi(apiClient),
errorHandlerStore)),
Provider<RiotResourcesService>(
create: (_) => RiotResourceServiceImpl()),
Provider<ClashBotEventsService>(
create: (_) => ClashBotEventsService()),
Provider<ErrorHandlerStore>(create: (_) => ErrorHandlerStore()),
ProxyProvider2<ClashBotService, ErrorHandlerStore, ClashStore>(
update: (_, clashBotService, errorHandlerStore, __) =>
ClashStore(clashBotService, errorHandlerStore)),
Expand Down Expand Up @@ -175,11 +179,6 @@ class Main extends StatelessWidget {
brightness: Brightness.dark,
colorScheme: darkColorScheme,
useMaterial3: true,
textTheme: const TextTheme(
// headlineLarge: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
// titleLarge: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
// bodyMedium: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
),
snackBarTheme: SnackBarThemeData(
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
Expand Down Expand Up @@ -312,8 +311,13 @@ class MainContainer extends StatelessWidget {
IconButton(
icon: const Icon(Icons.code),
tooltip: 'GitHub',
onPressed: () {
// Add your GitHub link or functionality here
onPressed: () async {
const url = 'https://github.com/Poss111/ClashBotFlutter';
if (await canLaunchUrl(Uri(path: url))) {
await launchUrl(Uri(path: url),
mode: LaunchMode.inAppBrowserView,
webOnlyWindowName: '_blank');
}
},
),
const Text(
Expand Down
31 changes: 31 additions & 0 deletions lib/pages/errorPages/whoops_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Whoops!'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 20,
children: [
Center(
child: Text(
'Something went wrong and we were not able to load what we needed. Our bot is working tirelessly to resolve the issue!',
style: Theme.of(context).textTheme.headlineSmall,
),
),
Text(
'Please check back at a later time.',
style: Theme.of(context).textTheme.headlineSmall,
),
],
),
);
}
}
112 changes: 60 additions & 52 deletions lib/pages/home/page/home_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import 'dart:developer' as developer;
import 'package:clash_bot_api/api.dart';
import 'package:clashbot_flutter/models/clash_team.dart';
import 'package:clashbot_flutter/models/discord_guild.dart';
import 'package:clashbot_flutter/pages/errorPages/whoops_page.dart';
import 'package:clashbot_flutter/pages/home/page/widgets/calendar_widget.dart';
import 'package:clashbot_flutter/pages/home/page/widgets/events_widget.dart';
import 'package:clashbot_flutter/pages/home/page/widgets/server_chip_list.dart';
import 'package:clashbot_flutter/stores/discord_details.store.dart';
import 'package:clashbot_flutter/stores/v2-stores/clash.store.dart';
import 'package:clashbot_flutter/stores/v2-stores/error_handler.store.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_svg/svg.dart';
Expand Down Expand Up @@ -92,60 +94,66 @@ class _HomeV2State extends State<HomeV2> {
ClashStore clashStore = context.read<ClashStore>();
DiscordDetailsStore discordDetailsStore =
context.read<DiscordDetailsStore>();
ErrorHandlerStore errorHandlerStore = context.read<ErrorHandlerStore>();
return Scaffold(
body: LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth > 500) {
return Row(
children: [
Flexible(
flex: 1,
child: Flex(direction: Axis.vertical, children: [
const ServerChipList(),
CalendarWidget(
focusedDay: _focusedDay,
selectedDay: _selectedDay,
clashStore: clashStore,
discordDetailsStore: discordDetailsStore),
Expanded(
child: Card.filled(
color: Theme.of(context).brightness == Brightness.dark
? Colors.blueGrey
: Colors.blueAccent,
margin: const EdgeInsets.all(16.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SvgPicture.asset(
'svgs/ClashBot-HomePage.svg',
semanticsLabel: 'Clash Bot Home Page',
width: 100,
height: 600,
),
body: Observer(
builder: (_) => errorHandlerStore.irreconcilable
? const WhoopsPage()
: LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth > 500) {
return Row(
children: [
Flexible(
flex: 1,
child: Flex(direction: Axis.vertical, children: [
const ServerChipList(),
CalendarWidget(
focusedDay: _focusedDay,
selectedDay: _selectedDay,
clashStore: clashStore,
discordDetailsStore: discordDetailsStore),
Expanded(
child: Card.filled(
color: Theme.of(context).brightness ==
Brightness.dark
? Colors.blueGrey
: Colors.blueAccent,
margin: const EdgeInsets.all(16.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: SvgPicture.asset(
'svgs/ClashBot-HomePage.svg',
semanticsLabel: 'Clash Bot Home Page',
width: 100,
height: 600,
),
),
),
),
]),
),
),
),
]),
),
const Flexible(
flex: 2,
child: EventsListWidget(),
),
],
);
} else {
return Column(
children: [
ServerChipList(),
CalendarWidget(
focusedDay: _focusedDay,
selectedDay: _selectedDay,
clashStore: clashStore,
discordDetailsStore: discordDetailsStore),
EventsListWidget(),
],
);
}
},
const Flexible(
flex: 2,
child: EventsListWidget(),
),
],
);
} else {
return Column(
children: [
ServerChipList(),
CalendarWidget(
focusedDay: _focusedDay,
selectedDay: _selectedDay,
clashStore: clashStore,
discordDetailsStore: discordDetailsStore),
EventsListWidget(),
],
);
}
},
),
),
floatingActionButton: Observer(
builder: (_) => clashStore.canCreateTeam
Expand Down
1 change: 1 addition & 0 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ const String GETTING_STARTED_ROUTE = '/getting-started';
const String TEAMS_DASHBOARD_ROUTE = '/teams';
const String SETTINGS_ROUTE = '/settings';
const String HOME_ROUTE = '/home';
const String WHOOPS_ROUTE = '/whoops';
Loading