Skip to content

Commit

Permalink
small cleaning of the project structure
Browse files Browse the repository at this point in the history
+ ipify api
+ dotenv package
+ setting page
  • Loading branch information
Fabio-web committed Jan 27, 2022
1 parent ab1d477 commit 14d5e36
Show file tree
Hide file tree
Showing 14 changed files with 502 additions and 225 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IPIFY_API_KEY=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.env.development
.env.production

# Miscellaneous
*.class
*.log
Expand Down
21 changes: 21 additions & 0 deletions lib/app/modules/home/global/binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


import 'package:get/get.dart';
import 'package:speed_test_app/app/data/providers/speedtest/storage_provider.dart';
import 'package:speed_test_app/app/data/services/storage/repository.dart';
import 'package:speed_test_app/app/modules/home/controller.dart';
import 'package:speed_test_app/app/modules/home/global/controller.dart';
import 'package:speed_test_app/app/modules/settings/controller.dart';

class GlobalBinding implements Bindings {

@override
void dependencies() {
Get.lazyPut<GlobalController>(() => GlobalController());
Get.lazyPut<HomeController>(() => HomeController(
speedtestRepository: SpeedtestRepository(
speedtestStorageProvider: SpeedtestStorageProvider())));
Get.lazyPut<SettingsController>(() => SettingsController());
}

}
17 changes: 17 additions & 0 deletions lib/app/modules/home/global/controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:get/get.dart';

class GlobalController extends GetxController {

final pageIndex = 0.obs;

GlobalController();

void changePageIndex(int index) {
pageIndex.value = index != 2 ? index : 0;
}

int getPageIndex() {
return pageIndex.value;
}

}
44 changes: 44 additions & 0 deletions lib/app/modules/home/global/view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:speed_test_app/app/core/values/colors.dart';
import 'package:speed_test_app/app/modules/home/global/controller.dart';
import 'package:speed_test_app/app/modules/home/global/widgets/bottom_nav_bar.dart';
import 'package:speed_test_app/app/modules/home/view.dart';
import 'package:speed_test_app/app/modules/settings/view.dart';

class GlobalPage extends GetView<GlobalController> {

const GlobalPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
body: Obx(() => IndexedStack(
index: controller.getPageIndex(),
children: [
const HomePage(),
const SizedBox(),
const SizedBox(),
const SizedBox(),
SettingsPage()
],
)),
floatingActionButton: FloatingActionButton(
onPressed: () {},
backgroundColor: primary,
elevation: 0,
enableFeedback: true,
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: 2),
borderRadius: BorderRadius.circular(50)
),
child: const Icon(Icons.arrow_upward_rounded)
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomNavBar()
);
}

}
58 changes: 58 additions & 0 deletions lib/app/modules/home/global/widgets/bottom_nav_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:speed_test_app/app/core/values/colors.dart';
import 'package:speed_test_app/app/modules/home/global/controller.dart';

class BottomNavBar extends StatelessWidget {

final controller = Get.find<GlobalController>();

BottomNavBar({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border(top: BorderSide(color: Colors.grey[200]!))
),
child: Obx(() => BottomNavigationBar(
onTap: (int index) => controller.changePageIndex(index),
elevation: 0,
currentIndex: controller.pageIndex.value,
showSelectedLabels: false,
showUnselectedLabels: false,
enableFeedback: true,
unselectedItemColor: primary,
selectedItemColor: accent,
type: BottomNavigationBarType.fixed,
items: const [
BottomNavigationBarItem(
label: 'home',
tooltip: "",
icon: Icon(Icons.cottage_outlined)
),
BottomNavigationBarItem(
label: 'statistics',
tooltip: "",
icon: Icon(Icons.bar_chart)
),
BottomNavigationBarItem(
label: '',
tooltip: "",
icon: Icon(Icons.arrow_upward_outlined, color: Colors.transparent)
),
BottomNavigationBarItem(
label: 'history',
tooltip: "",
icon: Icon(Icons.check_circle_outlined)
),
BottomNavigationBarItem(
label: 'settings',
tooltip: "",
icon: Icon(Icons.settings_outlined)
)
],
))
);
}
}
Loading

0 comments on commit 14d5e36

Please sign in to comment.