Added examples and screenshots
@@ -0,0 +1,122 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// TRY THIS: Try running your application with "flutter run". You'll see
|
||||
// the application has a purple toolbar. Then, without quitting the app,
|
||||
// try changing the seedColor in the colorScheme below to Colors.green
|
||||
// and then invoke "hot reload" (save your changes or press the "hot
|
||||
// reload" button in a Flutter-supported IDE, or press "r" if you used
|
||||
// the command line to start the app).
|
||||
//
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// state is not lost during the reload. To reset the state, use hot
|
||||
// restart instead.
|
||||
//
|
||||
// This works for code too, not just values: Most code changes can be
|
||||
// tested with just a hot reload.
|
||||
colorScheme: .fromSeed(seedColor: Colors.deepPurple),
|
||||
),
|
||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key, required this.title});
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
_counter++;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// TRY THIS: Try changing the color here to a specific color (to
|
||||
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
|
||||
// change color while the other colors stay the same.
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(
|
||||
// Center is a layout widget. It takes a single child and positions it
|
||||
// in the middle of the parent.
|
||||
child: Column(
|
||||
// Column is also a layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
//
|
||||
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
|
||||
// action in the IDE, or press "p" in the console), to see the
|
||||
// wireframe for each widget.
|
||||
mainAxisAlignment: .center,
|
||||
children: [
|
||||
const Text('You have pushed the button this many times:'),
|
||||
Text(
|
||||
'$_counter',
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// A single-line comment
|
||||
const maxCount = 10
|
||||
|
||||
/*
|
||||
* A multi-line
|
||||
* comment
|
||||
*/
|
||||
func main() {
|
||||
message := "Hello, Go!"
|
||||
count := 0
|
||||
|
||||
for i := 0; i < maxCount; i++ {
|
||||
fmt.Println(message + " - " + strconv.Itoa(i))
|
||||
count++
|
||||
}
|
||||
|
||||
if count > 5 {
|
||||
fmt.Println("Count is greater than 5")
|
||||
} else {
|
||||
fmt.Println("Count is not greater than 5")
|
||||
}
|
||||
|
||||
// Example with a slice
|
||||
names := []string{"Alice", "Bob", "Charlie"}
|
||||
for i, name := range names {
|
||||
fmt.Printf("Index: %d, Name: %s\n", i, name)
|
||||
}
|
||||
|
||||
// Function call with a struct
|
||||
user := User{ID: 1, Name: "0xtz"}
|
||||
user.Display()
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int
|
||||
Name string
|
||||
}
|
||||
|
||||
func (u User) Display() {
|
||||
fmt.Printf("User ID: %d, Name: %s\n", u.ID, u.Name)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
public class AndromedaShowcase {
|
||||
|
||||
// A single-line comment
|
||||
private static final int MAX_COUNT = 100;
|
||||
|
||||
/*
|
||||
* A multi-line
|
||||
* comment
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String greeting = "Hello, World!";
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
System.out.println(greeting + " - " + i);
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count > MAX_COUNT) {
|
||||
System.out.println("Count exceeded max!");
|
||||
} else {
|
||||
System.out.println("Count is: " + count);
|
||||
}
|
||||
|
||||
// Example of a data structure
|
||||
String[] names = {"Alice", "Bob", "Charlie"};
|
||||
for (String name : names) {
|
||||
System.out.println("Name: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// A single-line comment
|
||||
const MAX_COUNT = 10;
|
||||
|
||||
/*
|
||||
* A multi-line
|
||||
* comment
|
||||
*/
|
||||
function calculateSum(a, b) {
|
||||
let result = 0;
|
||||
for (let i = 0; i < MAX_COUNT; i++) {
|
||||
result += a + b;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const numbers = [10, 20, 30];
|
||||
const doubledNumbers = numbers.map((num) => num * 2);
|
||||
|
||||
console.log("Doubled Numbers:", doubledNumbers);
|
||||
|
||||
const sum = calculateSum(5, 7);
|
||||
console.log("Calculated Sum:", sum);
|
||||
|
||||
// Example of conditional logic
|
||||
const isValid = true;
|
||||
if (isValid) {
|
||||
console.log("Data is valid.");
|
||||
} else {
|
||||
console.log("Data is invalid.");
|
||||
}
|
||||
|
||||
// String interpolation
|
||||
const greeting = "JavaScript";
|
||||
console.log(`Hello, ${greeting}!`);
|
||||
@@ -0,0 +1,39 @@
|
||||
class User:
|
||||
def __init__(self, user_id: int, name: str):
|
||||
self.user_id = user_id
|
||||
self.name = name
|
||||
|
||||
def display(self):
|
||||
print(f"User ID: {self.user_id}, Name: {self.name}")
|
||||
|
||||
def main():
|
||||
# A single-line comment
|
||||
count = 0
|
||||
MAX_COUNT = 5
|
||||
|
||||
"""
|
||||
A multi-line
|
||||
comment
|
||||
"""
|
||||
for i in range(MAX_COUNT):
|
||||
print(f"Iteration: {i}")
|
||||
count += 1
|
||||
|
||||
if count > 0:
|
||||
message = "Count is positive!"
|
||||
else:
|
||||
message = "Count is zero!"
|
||||
|
||||
print(message)
|
||||
|
||||
# Example with a list
|
||||
names = ["Alice", "Bob", "Charlie"]
|
||||
for name in names:
|
||||
print(f"Name: {name}")
|
||||
|
||||
# Function call with a class instance
|
||||
user = User(1, "0xtz")
|
||||
user.display()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,84 @@
|
||||
import type React from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
interface Item {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export default function AndromedaThemeShowcase() {
|
||||
const [count, setCount] = useState<number>(0);
|
||||
const [items, setItems] = useState<Item[]>([
|
||||
{ id: 1, name: "First Item" },
|
||||
{ id: 2, name: "Second Item" },
|
||||
]);
|
||||
const API_URL: string = "https://api.example.com/data";
|
||||
|
||||
useEffect(() => {
|
||||
// Single-line comment
|
||||
console.log(`Component mounted or count changed: ${count}`);
|
||||
|
||||
/*
|
||||
* Multi-line
|
||||
* comment block
|
||||
*/
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const response = await fetch(API_URL);
|
||||
const data = await response.json();
|
||||
setItems((prevItems) => [...prevItems, ...data]);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error("Error fetching data:", error.message);
|
||||
} else {
|
||||
console.error("An unknown error occurred:", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
|
||||
return () => {
|
||||
console.log("Component unmounted or count changed.");
|
||||
};
|
||||
}, [count]);
|
||||
|
||||
const handleIncrement = (): void => {
|
||||
setCount((prevCount) => prevCount + 1);
|
||||
};
|
||||
|
||||
const renderItems = (): React.JSX.Element[] => {
|
||||
return items.map((item) => (
|
||||
<li key={item.id} style={{ color: "#00e8c6" }}>
|
||||
{item.name}
|
||||
</li>
|
||||
));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="andromeda-container">
|
||||
<h1>0xtz Theme React Showcase</h1>
|
||||
<p>
|
||||
Current Count: <span className="count-display">{count}</span>
|
||||
</p>
|
||||
<button onClick={handleIncrement} type="button">
|
||||
Increment Count
|
||||
</button>
|
||||
|
||||
<h2>Items:</h2>
|
||||
<ul>{renderItems()}</ul>
|
||||
|
||||
{/* This is a JSX comment */}
|
||||
{/**
|
||||
* Another multi-line JSX comment
|
||||
*/}
|
||||
|
||||
<p>
|
||||
API URL:{" "}
|
||||
<a href={API_URL} target="_blank" rel="noopener noreferrer">
|
||||
{API_URL}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
fn main() {
|
||||
// A single-line comment
|
||||
let mut count = 0;
|
||||
const MAX_ITERATIONS: u32 = 5;
|
||||
|
||||
/*
|
||||
* A multi-line
|
||||
* comment
|
||||
*/
|
||||
for i in 0..MAX_ITERATIONS {
|
||||
println!("Iteration: {}", i);
|
||||
count += 1;
|
||||
}
|
||||
|
||||
let message = if count > 0 {
|
||||
String::from("Count is positive!")
|
||||
} else {
|
||||
String::from("Count is zero!")
|
||||
};
|
||||
|
||||
println!("{}", message);
|
||||
|
||||
// Example with a vector
|
||||
let numbers = vec![10, 20, 30];
|
||||
for number in &numbers {
|
||||
println!("Number: {}", number);
|
||||
}
|
||||
|
||||
// Function call with a custom type
|
||||
let user = User { id: 1, name: String::from("hanskokx") };
|
||||
user.display();
|
||||
}
|
||||
|
||||
struct User {
|
||||
id: u32,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl User {
|
||||
fn display(&self) {
|
||||
println!("User ID: {}, Name: {}", self.id, self.name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
interface User {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
class UserManager {
|
||||
private users: User[] = [];
|
||||
|
||||
constructor(initialUsers: User[]) {
|
||||
this.users = initialUsers;
|
||||
}
|
||||
|
||||
// A single-line comment
|
||||
addUser(user: User): void {
|
||||
this.users.push(user);
|
||||
}
|
||||
|
||||
/*
|
||||
* A multi-line
|
||||
* comment
|
||||
*/
|
||||
displayUsers(): void {
|
||||
for (const user of this.users) {
|
||||
console.log(`User ID: ${user.id}, Name: ${user.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
static greet(name: string): string {
|
||||
const message: string = `Hello, ${name}!`;
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
function initializeAndromedaShowcase(): void {
|
||||
const initialUsers: User[] = [
|
||||
{ id: 1, name: "Alice" },
|
||||
{ id: 2, name: "Bob" },
|
||||
];
|
||||
const manager = new UserManager(initialUsers);
|
||||
|
||||
manager.addUser({ id: 3, name: "Charlie" });
|
||||
manager.displayUsers();
|
||||
|
||||
console.log(UserManager.greet("TypeScript"));
|
||||
|
||||
const isValid: boolean = true;
|
||||
if (isValid) {
|
||||
console.log("Validation successful.");
|
||||
} else {
|
||||
console.log("Validation failed.");
|
||||
}
|
||||
}
|
||||
|
||||
initializeAndromedaShowcase();
|
||||
|
After Width: | Height: | Size: 268 KiB |
|
After Width: | Height: | Size: 157 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 145 KiB |
|
After Width: | Height: | Size: 159 KiB |
|
After Width: | Height: | Size: 200 KiB |
|
After Width: | Height: | Size: 155 KiB |