Skip to content
Open
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
Empty file modified .gitignore
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions .metadata
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 8661d8aecd626f7f57ccbcb735553edc05a2e713
channel: stable
revision: db6e2d8aa5bb9a0bd3e75fc7470268b5a56fd0b0
channel: dev

project_type: app
1 change: 1 addition & 0 deletions LICENSE.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2019 Brian Robles
Copyright (c) 2020 Anirban Dutta

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
200 changes: 7 additions & 193 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,203 +1,17 @@
# ![Elements Logo](assets/launcher_icons/app_icon.png) Elements
# Elements

Browse the elements of the periodic table!
[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-white.svg)](https://snapcraft.io/elements)

Elements is a Flutter app developed for the Flutter Create 2019 contest. The app lets you browse the chemical elements of the Periodic Table. It also includes helpful snippets of information about each element.
A truly cross-platform Periodic table app built with Google's Flutter framework.

This is a cross-platform app that runs on both Android and iOS.


## Getting Started

This application can be run as is via

```
flutter run --release
```

The included dart script, `buildJson.dart`, can be run to generate a new `elementsGrid.json` file in the assets folder, to be used directly by the application. The script will automatically download a short Wikipedia extract and merge it with IUPAC-provided chemical element information and app-specific color values.
The <a href = "https://github.com/go-flutter-desktop/hover">Hover</a> framework was used to build packages such as Windows msi, MacOS dmg, and distro-specific linux packages as the flutter sdk currently only supports packaging as a snap(let me know if I am wrong).


## Screenshots
![Screencast](assets/screenshots/screencast.gif)

![Screenshot 1](assets/screenshots/screenshot_1.png)
![Screenshot 2](assets/screenshots/screenshot_2.png)
![Screenshot 3](assets/screenshots/screenshot_3.png)
![Screenshot 4](assets/screenshots/screenshot_4.png)


## Code

``` dart
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';


const kRowCount = 10;

const kContentSize = 64.0;
const kGutterWidth = 2.0;

const kGutterInset = EdgeInsets.all(kGutterWidth);


void main() {
final gridList = rootBundle.loadString('assets/elementsGrid.json')
.then((source) => jsonDecode(source)['elements'] as List)
.then((list) => list.map((json) => json != null ? ElementData.fromJson(json) : null).toList());

runApp(ElementsApp(gridList));
}


class ElementData {

final String name, category, symbol, extract, source, atomicWeight;
final int number;
final List<Color> colors;

ElementData.fromJson(Map<String, dynamic> json)
: name = json['name'], category = json['category'], symbol = json['symbol'],
extract = json['extract'], source = json['source'],
atomicWeight = json['atomic_weight'], number = json['number'],
colors = (json['colors'] as List).map((value) => Color(value)).toList();
}


class ElementsApp extends StatelessWidget {
ElementsApp(this.gridList);

final Future<List<ElementData>> gridList;

@override
Widget build(BuildContext context) {
final theme = ThemeData(
brightness: Brightness.dark,
accentColor: Colors.grey,

textTheme: Typography.whiteMountainView.apply(fontFamily: 'Roboto Condensed'),
primaryTextTheme: Typography.whiteMountainView.apply(fontFamily: 'Share Tech Mono'),
);

return MaterialApp(title: 'Elements', theme: theme, home: TablePage(gridList));
}
}

class TablePage extends StatelessWidget {
TablePage(this.gridList);

final Future<List<ElementData>> gridList;

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueGrey[900],
appBar: AppBar(title: Text('Elements'), centerTitle: true, backgroundColor: Colors.blueGrey[800]),
body: FutureBuilder(
future: gridList,
builder: (_, snapshot) => snapshot.hasData ? _buildTable(snapshot.data)
: Center(child: CircularProgressIndicator()),
),
);
}

Widget _buildTable(List<ElementData> elements) {
final tiles = elements.map((element) => element != null ? ElementTile(element)
: Container(color: Colors.black38, margin: kGutterInset)).toList();

return SingleChildScrollView(
child: SizedBox(height: kRowCount * (kContentSize + (kGutterWidth * 2)),
child: GridView.count(crossAxisCount: kRowCount, children: tiles,
scrollDirection: Axis.horizontal,),),);
}
}

class DetailPage extends StatelessWidget {
DetailPage(this.element);

final ElementData element;

@override
Widget build(BuildContext context) {
final listItems = <Widget>[
ListTile(leading: Icon(Icons.category), title : Text(element.category.toUpperCase())),
ListTile(leading: Icon(Icons.info), title : Text(element.extract),
subtitle: Text(element.source),),
ListTile(leading: Icon(Icons.fiber_smart_record), title: Text(element.atomicWeight),
subtitle: Text('Atomic Weight'),),
].expand((widget) => [widget, Divider()]).toList();

return Scaffold(
backgroundColor: Color.lerp(Colors.grey[850], element.colors[0], 0.07),

appBar: AppBar(
backgroundColor: Color.lerp(Colors.grey[850], element.colors[1], 0.2),
bottom: ElementTile(element, isLarge: true),),

body: ListView(padding: EdgeInsets.only(top: 24.0), children: listItems),
);
}
}


class ElementTile extends StatelessWidget implements PreferredSizeWidget {
const ElementTile(this.element, { this.isLarge = false });

final ElementData element;
final bool isLarge;

Size get preferredSize => Size.fromHeight(kContentSize * 1.5);

@override
Widget build(BuildContext context) {
final tileText = <Widget>[
Align(alignment: AlignmentDirectional.centerStart,
child: Text('${element.number}', style: TextStyle(fontSize: 10.0)),),
Text(element.symbol, style: Theme.of(context).primaryTextTheme.headline),
Text(element.name, maxLines: 1, overflow: TextOverflow.ellipsis,
textScaleFactor: isLarge ? 0.65 : 1,),
];

final tile = Container(
margin: kGutterInset,
width: kContentSize,
height: kContentSize,
foregroundDecoration: BoxDecoration(
gradient: LinearGradient(colors: element.colors),
backgroundBlendMode: BlendMode.multiply,),
child: RawMaterialButton(
onPressed: !isLarge ? () => Navigator.push(context,
MaterialPageRoute(builder: (_) => DetailPage(element))) : null,
fillColor: Colors.grey[800],
disabledElevation: 10.0,
padding: kGutterInset * 2.0,
child: Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: tileText),
),
);

return Hero(
tag: 'hero-${element.symbol}',
flightShuttleBuilder: (_, anim, __, ___, ____) =>
ScaleTransition(scale: anim.drive(Tween(begin: 1, end: 1.75)), child: tile),
child: Transform.scale(scale: isLarge ? 1.75 : 1, child: tile),
);
}
}
```

###### Total Dart Code Size: 5102 bytes


### Thanks to
- **Google Flutter Team**
- **Wikimedia Foundation** - Summary extracts from Wikipedia
- **IUPAC** - Chemical element information
- **Cathy** and **Joe** - for letting me use their laptop and wifi, respectively
### Desktop Version:

<img src = "Screenshot from 2020-10-12 01-55-27.png"> </img>

----
<img src = "Screenshot from 2020-10-12 02-04-52.png"> </img>

*Brian Carlos L. Robles (2019)*
Binary file added Screenshot from 2020-10-12 01-55-27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshot from 2020-10-12 02-04-52.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
16 changes: 9 additions & 7 deletions android/app/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,27 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 29

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.brianrobles204.elements_app"
applicationId "com.example.Elements"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand All @@ -55,7 +59,5 @@ flutter {
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.brianrobles204.elements_app">
package="com.example.Elements">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
40 changes: 24 additions & 16 deletions android/app/src/main/AndroidManifest.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.brianrobles204.elements_app">

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
package="com.example.Elements">
<application
android:label="Elements"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in @style/LaunchTheme). -->
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.Elements

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion android/app/src/main/res/drawable/launch_background.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
Expand Down
5 changes: 0 additions & 5 deletions android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading