I dont want to do this anymore
This commit is contained in:
@@ -5,4 +5,6 @@ public class Config {
|
|||||||
public boolean showBiomeInRPC = true;
|
public boolean showBiomeInRPC = true;
|
||||||
public boolean showHeldItemInRPC = true;
|
public boolean showHeldItemInRPC = true;
|
||||||
public boolean showHealthInRPC = true;
|
public boolean showHealthInRPC = true;
|
||||||
|
public boolean enableSmoothUI = true;
|
||||||
|
public boolean enableCompactMode = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,130 +1,98 @@
|
|||||||
package de.winniepat.parrotmod.ui;
|
package de.winniepat.parrotmod.ui;
|
||||||
|
|
||||||
|
import de.winniepat.parrotmod.ui.util.ParrotTheme;
|
||||||
import icyllis.modernui.animation.ObjectAnimator;
|
import icyllis.modernui.animation.ObjectAnimator;
|
||||||
import icyllis.modernui.fragment.Fragment;
|
import icyllis.modernui.fragment.Fragment;
|
||||||
import icyllis.modernui.graphics.drawable.ShapeDrawable;
|
|
||||||
import icyllis.modernui.view.Gravity;
|
import icyllis.modernui.view.Gravity;
|
||||||
import icyllis.modernui.view.View;
|
import icyllis.modernui.view.View;
|
||||||
import icyllis.modernui.view.ViewGroup;
|
import icyllis.modernui.view.ViewGroup;
|
||||||
import icyllis.modernui.widget.LinearLayout;
|
import icyllis.modernui.widget.LinearLayout;
|
||||||
|
import icyllis.modernui.widget.Switch;
|
||||||
import icyllis.modernui.widget.TextView;
|
import icyllis.modernui.widget.TextView;
|
||||||
|
|
||||||
public abstract class BaseTabFragment extends Fragment {
|
public abstract class BaseTabFragment extends Fragment {
|
||||||
|
|
||||||
protected static final int COLOR_CARD = 0xFF23232D;
|
protected void animateChildren(ViewGroup group) {
|
||||||
protected static final int COLOR_ACCENT = 0xFF5CF392;
|
for (int i = 0; i < group.getChildCount(); i++) {
|
||||||
protected static final int COLOR_ACCENT_DIM = 0xFF3E8E5A;
|
View child = group.getChildAt(i);
|
||||||
protected static final int COLOR_TEXT_MAIN = 0xFFF0F0F0;
|
child.setAlpha(0);
|
||||||
protected static final int COLOR_TEXT_SEC = 0xFF9EA3AF;
|
child.setTranslationX(ParrotTheme.dp(20));
|
||||||
protected static final int COLOR_CARD_BORDER = 0x265CF392;
|
|
||||||
|
|
||||||
protected int dp(float dp) {
|
ObjectAnimator alpha = ObjectAnimator.ofFloat(child, View.ALPHA, 0, 1);
|
||||||
return (int) (dp * getContext().getResources().getDisplayMetrics().density);
|
alpha.setDuration(400);
|
||||||
|
alpha.setStartDelay(i * 40L);
|
||||||
|
alpha.start();
|
||||||
|
|
||||||
|
ObjectAnimator slide = ObjectAnimator.ofFloat(child, View.TRANSLATION_X, ParrotTheme.dp(20), 0);
|
||||||
|
slide.setDuration(500);
|
||||||
|
slide.setStartDelay(i * 40L);
|
||||||
|
slide.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TextView makeLabel(String text) {
|
protected void addPageHeader(LinearLayout parent, String title, String subtitle) {
|
||||||
TextView tv = new TextView(getContext());
|
LinearLayout headerBox = new LinearLayout(getContext());
|
||||||
tv.setText(text);
|
headerBox.setOrientation(LinearLayout.VERTICAL);
|
||||||
tv.setTextSize(14);
|
headerBox.setPadding(0, 0, 0, ParrotTheme.dp(24));
|
||||||
tv.setTextColor(COLOR_TEXT_MAIN);
|
|
||||||
var p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
TextView titleView = new TextView(getContext());
|
||||||
p.topMargin = dp(12);
|
titleView.setText(title);
|
||||||
p.bottomMargin = dp(4);
|
titleView.setTextSize(28);
|
||||||
tv.setLayoutParams(p);
|
titleView.setTextColor(ParrotTheme.TEXT_TITLE);
|
||||||
return tv;
|
headerBox.addView(titleView);
|
||||||
|
|
||||||
|
TextView subView = new TextView(getContext());
|
||||||
|
subView.setText(subtitle);
|
||||||
|
subView.setTextSize(14);
|
||||||
|
subView.setTextColor(ParrotTheme.NEON_ACCENT);
|
||||||
|
headerBox.addView(subView);
|
||||||
|
|
||||||
|
parent.addView(headerBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addSectionHeader(LinearLayout parent, String title) {
|
protected void addSectionLabel(LinearLayout parent, String title) {
|
||||||
TextView tv = new TextView(getContext());
|
TextView tv = new TextView(getContext());
|
||||||
tv.setText(title.toUpperCase());
|
tv.setText(title.toUpperCase());
|
||||||
tv.setTextSize(11);
|
tv.setTextSize(12);
|
||||||
tv.setTextColor(COLOR_ACCENT);
|
tv.setTextColor(ParrotTheme.TEXT_SUBTITLE);
|
||||||
var p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
var p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
p.topMargin = dp(24);
|
p.topMargin = ParrotTheme.dp(16);
|
||||||
p.bottomMargin = dp(10);
|
p.bottomMargin = ParrotTheme.dp(12);
|
||||||
p.leftMargin = dp(4);
|
|
||||||
parent.addView(tv, p);
|
parent.addView(tv, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addTabHeader(LinearLayout parent, String title, String description) {
|
protected LinearLayout createToggleCard(String title, String desc, boolean isChecked, Switch.OnCheckedChangeListener listener) {
|
||||||
TextView titleView = new TextView(getContext());
|
|
||||||
titleView.setText(title);
|
|
||||||
titleView.setTextSize(24);
|
|
||||||
titleView.setTextColor(0xFFFFFFFF);
|
|
||||||
titleView.setPadding(0, 0, 0, dp(2));
|
|
||||||
parent.addView(titleView);
|
|
||||||
|
|
||||||
if (description != null) {
|
|
||||||
TextView descView = new TextView(getContext());
|
|
||||||
descView.setText(description);
|
|
||||||
descView.setTextSize(13);
|
|
||||||
descView.setTextColor(COLOR_TEXT_SEC);
|
|
||||||
descView.setPadding(0, 0, 0, dp(16));
|
|
||||||
parent.addView(descView);
|
|
||||||
}
|
|
||||||
|
|
||||||
View divider = new View(getContext());
|
|
||||||
var divParams = new LinearLayout.LayoutParams(dp(40), dp(3));
|
|
||||||
divParams.bottomMargin = dp(16);
|
|
||||||
divider.setLayoutParams(divParams);
|
|
||||||
divider.setBackground(makeRoundedBg(COLOR_ACCENT, 2));
|
|
||||||
parent.addView(divider);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LinearLayout createSettingCard(String title, String description) {
|
|
||||||
LinearLayout card = new LinearLayout(getContext());
|
LinearLayout card = new LinearLayout(getContext());
|
||||||
card.setOrientation(LinearLayout.HORIZONTAL);
|
card.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
card.setGravity(Gravity.CENTER_VERTICAL);
|
card.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
card.setPadding(dp(18), dp(14), dp(18), dp(14));
|
card.setPadding(ParrotTheme.dp(20), ParrotTheme.dp(16), ParrotTheme.dp(20), ParrotTheme.dp(16));
|
||||||
card.setBackground(makeBorderedBg(COLOR_CARD, COLOR_CARD_BORDER, 10, 1));
|
card.setBackground(ParrotTheme.createCard(12));
|
||||||
|
|
||||||
var cardParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
var cardParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
cardParams.bottomMargin = dp(10);
|
cardParams.bottomMargin = ParrotTheme.dp(12);
|
||||||
card.setLayoutParams(cardParams);
|
card.setLayoutParams(cardParams);
|
||||||
|
|
||||||
LinearLayout textLayout = new LinearLayout(getContext());
|
LinearLayout textLayout = new LinearLayout(getContext());
|
||||||
textLayout.setOrientation(LinearLayout.VERTICAL);
|
textLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
var textParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f);
|
card.addView(textLayout, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
card.addView(textLayout, textParams);
|
|
||||||
|
|
||||||
TextView titleView = new TextView(getContext());
|
TextView titleView = new TextView(getContext());
|
||||||
titleView.setText(title);
|
titleView.setText(title);
|
||||||
titleView.setTextSize(15.5f);
|
titleView.setTextSize(16);
|
||||||
titleView.setTextColor(COLOR_TEXT_MAIN);
|
titleView.setTextColor(ParrotTheme.TEXT_TITLE);
|
||||||
textLayout.addView(titleView);
|
textLayout.addView(titleView);
|
||||||
|
|
||||||
if (description != null) {
|
TextView descView = new TextView(getContext());
|
||||||
TextView descView = new TextView(getContext());
|
descView.setText(desc);
|
||||||
descView.setText(description);
|
descView.setTextSize(13);
|
||||||
descView.setTextSize(12.5f);
|
descView.setTextColor(ParrotTheme.TEXT_SUBTITLE);
|
||||||
descView.setTextColor(COLOR_TEXT_SEC);
|
textLayout.addView(descView);
|
||||||
textLayout.addView(descView);
|
|
||||||
}
|
Switch toggle = new Switch(getContext());
|
||||||
|
toggle.setChecked(isChecked);
|
||||||
|
toggle.setOnCheckedChangeListener(listener);
|
||||||
|
card.addView(toggle);
|
||||||
|
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ShapeDrawable makeRoundedBg(int color, float radius) {
|
|
||||||
ShapeDrawable d = new ShapeDrawable();
|
|
||||||
d.setCornerRadius(dp(radius));
|
|
||||||
d.setColor(color);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ShapeDrawable makeBorderedBg(int color, int strokeColor, float radius, float strokeWidth) {
|
|
||||||
ShapeDrawable d = new ShapeDrawable();
|
|
||||||
d.setCornerRadius(dp(radius));
|
|
||||||
d.setColor(color);
|
|
||||||
d.setStroke(dp(strokeWidth), strokeColor);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, icyllis.modernui.util.DataSet savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
view.setAlpha(0);
|
|
||||||
view.setTranslationY(dp(10));
|
|
||||||
ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1).setDuration(400).start();
|
|
||||||
ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, dp(10), 0).setDuration(400).start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,92 +1,91 @@
|
|||||||
package de.winniepat.parrotmod.ui;
|
package de.winniepat.parrotmod.ui;
|
||||||
|
|
||||||
import de.winniepat.parrotmod.config.ConfigManager;
|
import de.winniepat.parrotmod.config.ConfigManager;
|
||||||
|
import de.winniepat.parrotmod.ui.util.ParrotTheme;
|
||||||
|
import icyllis.modernui.animation.ObjectAnimator;
|
||||||
import icyllis.modernui.util.DataSet;
|
import icyllis.modernui.util.DataSet;
|
||||||
import icyllis.modernui.view.LayoutInflater;
|
import icyllis.modernui.view.LayoutInflater;
|
||||||
import icyllis.modernui.view.View;
|
import icyllis.modernui.view.View;
|
||||||
import icyllis.modernui.view.ViewGroup;
|
import icyllis.modernui.view.ViewGroup;
|
||||||
import icyllis.modernui.widget.LinearLayout;
|
import icyllis.modernui.widget.LinearLayout;
|
||||||
import icyllis.modernui.widget.Switch;
|
|
||||||
import icyllis.modernui.widget.ScrollView;
|
import icyllis.modernui.widget.ScrollView;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DiscordTabFragment extends BaseTabFragment {
|
public class DiscordTabFragment extends BaseTabFragment {
|
||||||
|
|
||||||
private final List<View> rpcDetailViews = new ArrayList<>();
|
private LinearLayout contentLayout;
|
||||||
|
private LinearLayout subSettingsGroup;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
|
||||||
ScrollView scrollView = new ScrollView(getContext());
|
ScrollView scroll = new ScrollView(getContext());
|
||||||
scrollView.setFillViewport(true);
|
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(getContext());
|
contentLayout = new LinearLayout(getContext());
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
contentLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
layout.setPadding(dp(28), dp(24), dp(28), dp(24));
|
contentLayout.setPadding(ParrotTheme.dp(40), ParrotTheme.dp(40), ParrotTheme.dp(40), ParrotTheme.dp(40));
|
||||||
scrollView.addView(layout);
|
scroll.addView(contentLayout);
|
||||||
|
|
||||||
addTabHeader(layout, "Discord Rich Presence", "Connect your Minecraft activity to your Discord profile.");
|
addPageHeader(contentLayout, "Discord Rich Presence", "Broadcast your Minecraft activity.");
|
||||||
|
|
||||||
addSectionHeader(layout, "Core Integration");
|
addSectionLabel(contentLayout, "Core Integration");
|
||||||
|
|
||||||
addSwitchRow(layout, "Status Integration", "Toggle Discord Rich Presence globally.",
|
contentLayout.addView(createToggleCard("Enable Rich Presence", "Connect Parrot to your Discord client.",
|
||||||
ConfigManager.getInstance().enableDiscordRPC, (v, checked) -> {
|
ConfigManager.getInstance().enableDiscordRPC, (v, checked) -> {
|
||||||
ConfigManager.getInstance().enableDiscordRPC = checked;
|
ConfigManager.getInstance().enableDiscordRPC = checked;
|
||||||
ConfigManager.save();
|
ConfigManager.save();
|
||||||
updateRPCDetailsEnabled(checked);
|
animateSubSettingsState(checked);
|
||||||
});
|
}));
|
||||||
|
|
||||||
addSectionHeader(layout, "Status Customization");
|
addSectionLabel(contentLayout, "Activity Customization");
|
||||||
|
|
||||||
rpcDetailViews.add(addSwitchRow(layout, "Location Tracking", "Broadcast your current biome.",
|
subSettingsGroup = new LinearLayout(getContext());
|
||||||
|
subSettingsGroup.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
contentLayout.addView(subSettingsGroup);
|
||||||
|
|
||||||
|
subSettingsGroup.addView(createToggleCard("Location Tracking", "Broadcast your current biome and dimension.",
|
||||||
ConfigManager.getInstance().showBiomeInRPC, (v, checked) -> {
|
ConfigManager.getInstance().showBiomeInRPC, (v, checked) -> {
|
||||||
ConfigManager.getInstance().showBiomeInRPC = checked;
|
ConfigManager.getInstance().showBiomeInRPC = checked;
|
||||||
ConfigManager.save();
|
ConfigManager.save();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
rpcDetailViews.add(addSwitchRow(layout, "Equipment Status", "Show your currently held items.",
|
subSettingsGroup.addView(createToggleCard("Equipment Status", "Show your currently held items and armor.",
|
||||||
ConfigManager.getInstance().showHeldItemInRPC, (v, checked) -> {
|
ConfigManager.getInstance().showHeldItemInRPC, (v, checked) -> {
|
||||||
ConfigManager.getInstance().showHeldItemInRPC = checked;
|
ConfigManager.getInstance().showHeldItemInRPC = checked;
|
||||||
ConfigManager.save();
|
ConfigManager.save();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
rpcDetailViews.add(addSwitchRow(layout, "Vitality Info", "Display your current health status.",
|
subSettingsGroup.addView(createToggleCard("Vitality Info", "Display your exact health and hunger.",
|
||||||
ConfigManager.getInstance().showHealthInRPC, (v, checked) -> {
|
ConfigManager.getInstance().showHealthInRPC, (v, checked) -> {
|
||||||
ConfigManager.getInstance().showHealthInRPC = checked;
|
ConfigManager.getInstance().showHealthInRPC = checked;
|
||||||
ConfigManager.save();
|
ConfigManager.save();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
updateRPCDetailsEnabled(ConfigManager.getInstance().enableDiscordRPC);
|
applySubSettingsState(ConfigManager.getInstance().enableDiscordRPC);
|
||||||
|
|
||||||
return scrollView;
|
return scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRPCDetailsEnabled(boolean enabled) {
|
private void animateSubSettingsState(boolean enabled) {
|
||||||
for (View v : rpcDetailViews) {
|
float targetAlpha = enabled ? 1.0f : 0.4f;
|
||||||
v.setEnabled(enabled);
|
ObjectAnimator.ofFloat(subSettingsGroup, View.ALPHA, subSettingsGroup.getAlpha(), targetAlpha).setDuration(250).start();
|
||||||
v.setAlpha(enabled ? 1.0f : 0.5f);
|
setChildrenEnabled(subSettingsGroup, enabled);
|
||||||
if (v instanceof ViewGroup) {
|
|
||||||
setChildrenEnabled((ViewGroup) v, enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setChildrenEnabled(ViewGroup vg, boolean enabled) {
|
private void applySubSettingsState(boolean enabled) {
|
||||||
for (int i = 0; i < vg.getChildCount(); i++) {
|
subSettingsGroup.setAlpha(enabled ? 1.0f : 0.4f);
|
||||||
View child = vg.getChildAt(i);
|
setChildrenEnabled(subSettingsGroup, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setChildrenEnabled(ViewGroup group, boolean enabled) {
|
||||||
|
for (int i = 0; i < group.getChildCount(); i++) {
|
||||||
|
View child = group.getChildAt(i);
|
||||||
child.setEnabled(enabled);
|
child.setEnabled(enabled);
|
||||||
if (child instanceof ViewGroup) {
|
if (child instanceof ViewGroup vg) setChildrenEnabled(vg, enabled);
|
||||||
setChildrenEnabled((ViewGroup) child, enabled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private View addSwitchRow(LinearLayout parent, String title, String desc, boolean checked, Switch.OnCheckedChangeListener listener) {
|
@Override
|
||||||
LinearLayout card = createSettingCard(title, desc);
|
public void onViewCreated(View view, DataSet savedInstanceState) {
|
||||||
Switch s = new Switch(getContext());
|
super.onViewCreated(view, savedInstanceState);
|
||||||
s.setChecked(checked);
|
animateChildren(contentLayout);
|
||||||
s.setOnCheckedChangeListener(listener);
|
|
||||||
card.addView(s);
|
|
||||||
parent.addView(card);
|
|
||||||
return card;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,45 +1,49 @@
|
|||||||
package de.winniepat.parrotmod.ui;
|
package de.winniepat.parrotmod.ui;
|
||||||
|
|
||||||
import de.winniepat.parrotmod.config.ConfigManager;
|
import de.winniepat.parrotmod.config.ConfigManager;
|
||||||
|
import de.winniepat.parrotmod.ui.util.ParrotTheme;
|
||||||
import icyllis.modernui.util.DataSet;
|
import icyllis.modernui.util.DataSet;
|
||||||
import icyllis.modernui.view.LayoutInflater;
|
import icyllis.modernui.view.LayoutInflater;
|
||||||
import icyllis.modernui.view.View;
|
import icyllis.modernui.view.View;
|
||||||
import icyllis.modernui.view.ViewGroup;
|
import icyllis.modernui.view.ViewGroup;
|
||||||
import icyllis.modernui.widget.Button;
|
|
||||||
import icyllis.modernui.widget.LinearLayout;
|
import icyllis.modernui.widget.LinearLayout;
|
||||||
import net.minecraft.client.Minecraft;
|
import icyllis.modernui.widget.ScrollView;
|
||||||
|
|
||||||
public class GeneralTabFragment extends BaseTabFragment {
|
public class GeneralTabFragment extends BaseTabFragment {
|
||||||
|
|
||||||
|
private LinearLayout contentLayout;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
|
||||||
LinearLayout layout = new LinearLayout(getContext());
|
ScrollView scroll = new ScrollView(getContext());
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
layout.setPadding(dp(28), dp(24), dp(28), dp(24));
|
|
||||||
|
|
||||||
addTabHeader(layout, "Client Settings", "Configure your client-side experience and mod data.");
|
contentLayout = new LinearLayout(getContext());
|
||||||
|
contentLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
contentLayout.setPadding(ParrotTheme.dp(40), ParrotTheme.dp(40), ParrotTheme.dp(40), ParrotTheme.dp(40));
|
||||||
|
scroll.addView(contentLayout);
|
||||||
|
|
||||||
addSectionHeader(layout, "Information");
|
addPageHeader(contentLayout, "Client Settings", "Customize your gameplay experience.");
|
||||||
layout.addView(createSettingCard("Version", "Running on Minecraft " + Minecraft.getInstance().getLaunchedVersion()));
|
|
||||||
|
|
||||||
addSectionHeader(layout, "Data Management");
|
addSectionLabel(contentLayout, "Interface");
|
||||||
|
|
||||||
LinearLayout reloadCard = createSettingCard("Reload configuration", "Discard unsaved changes and reload from disk.");
|
contentLayout.addView(createToggleCard("Smooth Animations", "Enable fluid transitions across the mod GUI.",
|
||||||
Button reloadBtn = new Button(getContext());
|
ConfigManager.getInstance().enableSmoothUI, (v, checked) -> {
|
||||||
reloadBtn.setText("Reload");
|
ConfigManager.getInstance().enableSmoothUI = checked;
|
||||||
reloadBtn.setPadding(dp(16), 0, dp(16), 0);
|
ConfigManager.save();
|
||||||
reloadBtn.setOnClickListener(v -> ConfigManager.load());
|
}));
|
||||||
reloadCard.addView(reloadBtn);
|
|
||||||
layout.addView(reloadCard);
|
|
||||||
|
|
||||||
LinearLayout saveCard = createSettingCard("Commit changes", "Save all current settings to the configuration file.");
|
contentLayout.addView(createToggleCard("Compact Mode", "Reduce padding to show more information at once.",
|
||||||
Button saveBtn = new Button(getContext());
|
ConfigManager.getInstance().enableCompactMode, (v, checked) -> {
|
||||||
saveBtn.setText("Save");
|
ConfigManager.getInstance().enableCompactMode = checked;
|
||||||
saveBtn.setPadding(dp(16), 0, dp(16), 0);
|
ConfigManager.save();
|
||||||
saveBtn.setOnClickListener(v -> ConfigManager.save());
|
}));
|
||||||
saveCard.addView(saveBtn);
|
|
||||||
layout.addView(saveCard);
|
|
||||||
|
|
||||||
return layout;
|
return scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, DataSet savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
animateChildren(contentLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,48 +1,88 @@
|
|||||||
package de.winniepat.parrotmod.ui;
|
package de.winniepat.parrotmod.ui;
|
||||||
|
|
||||||
|
import de.winniepat.parrotmod.ui.util.ParrotTheme;
|
||||||
import icyllis.modernui.util.DataSet;
|
import icyllis.modernui.util.DataSet;
|
||||||
import icyllis.modernui.view.LayoutInflater;
|
import icyllis.modernui.view.LayoutInflater;
|
||||||
import icyllis.modernui.view.View;
|
import icyllis.modernui.view.View;
|
||||||
import icyllis.modernui.view.ViewGroup;
|
import icyllis.modernui.view.ViewGroup;
|
||||||
import icyllis.modernui.widget.LinearLayout;
|
import icyllis.modernui.widget.LinearLayout;
|
||||||
import icyllis.modernui.widget.ScrollView;
|
import icyllis.modernui.widget.ScrollView;
|
||||||
|
import icyllis.modernui.widget.TextView;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class InfoTabFragment extends BaseTabFragment {
|
public class InfoTabFragment extends BaseTabFragment {
|
||||||
|
|
||||||
|
private LinearLayout contentLayout;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
|
||||||
ScrollView scrollView = new ScrollView(getContext());
|
ScrollView scroll = new ScrollView(getContext());
|
||||||
scrollView.setFillViewport(true);
|
scroll.setFillViewport(true);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(getContext());
|
contentLayout = new LinearLayout(getContext());
|
||||||
layout.setOrientation(LinearLayout.VERTICAL);
|
contentLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
layout.setPadding(dp(28), dp(24), dp(28), dp(24));
|
contentLayout.setPadding(ParrotTheme.dp(40), ParrotTheme.dp(40), ParrotTheme.dp(40), ParrotTheme.dp(40));
|
||||||
scrollView.addView(layout);
|
scroll.addView(contentLayout);
|
||||||
|
|
||||||
addTabHeader(layout, "System Overview", "Detailed information about your environment and mod versions.");
|
addPageHeader(contentLayout, "System Dashboard", "Real-time environment analytics");
|
||||||
|
|
||||||
addSectionHeader(layout, "Software Manifest");
|
addSectionLabel(contentLayout, "Software Manifest");
|
||||||
String parrotVersion = FabricLoader.getInstance().getModContainer("parrotmod").orElseThrow().getMetadata().getVersion().getFriendlyString();
|
|
||||||
layout.addView(createSettingCard("ParrotMod", "Stable Build v" + parrotVersion));
|
|
||||||
|
|
||||||
String mcVersion = FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion().getFriendlyString();
|
LinearLayout row1 = new LinearLayout(getContext());
|
||||||
layout.addView(createSettingCard("Minecraft Engine", Minecraft.getInstance().getLaunchedVersion() + " (" + mcVersion + ")"));
|
row1.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
row1.addView(createStatGrid("Parrot Engine", "v" + FabricLoader.getInstance().getModContainer("parrotmod").orElseThrow().getMetadata().getVersion().getFriendlyString()), new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
|
|
||||||
String loaderVersion = FabricLoader.getInstance().getModContainer("fabricloader").orElseThrow().getMetadata().getVersion().getFriendlyString();
|
View spacer1 = new View(getContext());
|
||||||
layout.addView(createSettingCard("Fabric Loader", "Build " + loaderVersion));
|
row1.addView(spacer1, new LinearLayout.LayoutParams(ParrotTheme.dp(16), 1));
|
||||||
|
|
||||||
addSectionHeader(layout, "Runtime Environment");
|
row1.addView(createStatGrid("Minecraft", Minecraft.getInstance().getLaunchedVersion()), new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
layout.addView(createSettingCard("Java Runtime", System.getProperty("java.version") + " [" + System.getProperty("os.arch") + "]"));
|
contentLayout.addView(row1);
|
||||||
layout.addView(createSettingCard("Operating System", System.getProperty("os.name") + " [" + System.getProperty("os.version") + "]"));
|
|
||||||
|
|
||||||
long maxMemory = Runtime.getRuntime().maxMemory();
|
addSectionLabel(contentLayout, "Hardware Status");
|
||||||
long totalMemory = Runtime.getRuntime().totalMemory();
|
|
||||||
long freeMemory = Runtime.getRuntime().freeMemory();
|
|
||||||
long usedMemory = totalMemory - freeMemory;
|
|
||||||
layout.addView(createSettingCard("Memory Allocation", String.format("%d MiB / %d MiB in use", usedMemory / 1024 / 1024, maxMemory / 1024 / 1024)));
|
|
||||||
|
|
||||||
return scrollView;
|
LinearLayout row2 = new LinearLayout(getContext());
|
||||||
|
row2.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
|
||||||
|
long maxMem = Runtime.getRuntime().maxMemory() / 1024 / 1024;
|
||||||
|
long usedMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024;
|
||||||
|
|
||||||
|
row2.addView(createStatGrid("Memory Usage", usedMem + " / " + maxMem + " MB"), new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
|
|
||||||
|
View spacer2 = new View(getContext());
|
||||||
|
row2.addView(spacer2, new LinearLayout.LayoutParams(ParrotTheme.dp(16), 1));
|
||||||
|
|
||||||
|
row2.addView(createStatGrid("Architecture", System.getProperty("os.arch").toUpperCase()), new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
|
contentLayout.addView(row2);
|
||||||
|
|
||||||
|
return scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinearLayout createStatGrid(String label, String value) {
|
||||||
|
LinearLayout box = new LinearLayout(getContext());
|
||||||
|
box.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
box.setPadding(ParrotTheme.dp(20), ParrotTheme.dp(20), ParrotTheme.dp(20), ParrotTheme.dp(20));
|
||||||
|
box.setBackground(ParrotTheme.createCard(12));
|
||||||
|
|
||||||
|
TextView valTxt = new TextView(getContext());
|
||||||
|
valTxt.setText(value);
|
||||||
|
valTxt.setTextSize(20);
|
||||||
|
valTxt.setTextColor(ParrotTheme.NEON_ACCENT);
|
||||||
|
box.addView(valTxt);
|
||||||
|
|
||||||
|
TextView lblTxt = new TextView(getContext());
|
||||||
|
lblTxt.setText(label.toUpperCase());
|
||||||
|
lblTxt.setTextSize(11);
|
||||||
|
lblTxt.setTextColor(ParrotTheme.TEXT_MUTED);
|
||||||
|
lblTxt.setPadding(0, ParrotTheme.dp(4), 0, 0);
|
||||||
|
box.addView(lblTxt);
|
||||||
|
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, DataSet savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
animateChildren(contentLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,180 +1,114 @@
|
|||||||
package de.winniepat.parrotmod.ui;
|
package de.winniepat.parrotmod.ui;
|
||||||
|
|
||||||
|
import de.winniepat.parrotmod.ui.util.ParrotTheme;
|
||||||
import icyllis.modernui.R;
|
import icyllis.modernui.R;
|
||||||
import icyllis.modernui.animation.ObjectAnimator;
|
import icyllis.modernui.animation.ObjectAnimator;
|
||||||
import icyllis.modernui.fragment.Fragment;
|
import icyllis.modernui.fragment.Fragment;
|
||||||
import icyllis.modernui.util.DataSet;
|
import icyllis.modernui.util.DataSet;
|
||||||
import icyllis.modernui.view.*;
|
import icyllis.modernui.view.*;
|
||||||
import icyllis.modernui.widget.*;
|
import icyllis.modernui.widget.*;
|
||||||
import icyllis.modernui.graphics.drawable.ShapeDrawable;
|
|
||||||
import icyllis.modernui.graphics.*;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
|
|
||||||
public class SettingsFragment extends Fragment {
|
public class SettingsFragment extends Fragment {
|
||||||
|
|
||||||
private static final int COLOR_BACKGROUND = 0xFF18181F;
|
|
||||||
private static final int COLOR_SIDEBAR = 0xFF121217;
|
|
||||||
private static final int COLOR_ACCENT = 0xFF5CF392;
|
|
||||||
private static final int COLOR_TEXT_DIM = 0xFF9EA3AF;
|
|
||||||
private static final int COLOR_TAB_SELECTED = 0x125CF392;
|
|
||||||
private static final int COLOR_BORDER = 0x1AFFFFFF;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceState) {
|
||||||
FrameLayout root = new FrameLayout(getContext());
|
FrameLayout root = new FrameLayout(getContext());
|
||||||
root.setLayoutParams(new FrameLayout.LayoutParams(dp(760), dp(520), Gravity.CENTER));
|
root.setLayoutParams(new FrameLayout.LayoutParams(ParrotTheme.dp(840), ParrotTheme.dp(580), Gravity.CENTER));
|
||||||
|
|
||||||
View bg = new View(getContext());
|
View bg = new View(getContext());
|
||||||
bg.setBackground(makeBorderedBg(COLOR_BACKGROUND, COLOR_BORDER, 14, 1.2f));
|
bg.setBackground(ParrotTheme.createGlassPanel(16, 1.5f));
|
||||||
root.addView(bg);
|
root.addView(bg);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(getContext());
|
LinearLayout layout = new LinearLayout(getContext());
|
||||||
layout.setOrientation(LinearLayout.HORIZONTAL);
|
layout.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
root.addView(layout);
|
root.addView(layout);
|
||||||
|
|
||||||
FrameLayout sidebarContainer = new FrameLayout(getContext());
|
LinearLayout sidebar = new LinearLayout(getContext());
|
||||||
var sidebarParams = new LinearLayout.LayoutParams(dp(190), ViewGroup.LayoutParams.MATCH_PARENT);
|
sidebar.setOrientation(LinearLayout.VERTICAL);
|
||||||
layout.addView(sidebarContainer, sidebarParams);
|
sidebar.setPadding(ParrotTheme.dp(20), ParrotTheme.dp(32), ParrotTheme.dp(20), ParrotTheme.dp(24));
|
||||||
|
layout.addView(sidebar, new LinearLayout.LayoutParams(ParrotTheme.dp(220), ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
View sidebarBg = new View(getContext());
|
|
||||||
sidebarBg.setBackground(makeRoundedBg(COLOR_SIDEBAR, 14));
|
|
||||||
sidebarContainer.addView(sidebarBg);
|
|
||||||
|
|
||||||
LinearLayout sidebarContent = new LinearLayout(getContext());
|
|
||||||
sidebarContent.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
sidebarContent.setPadding(0, dp(28), 0, dp(16));
|
|
||||||
sidebarContainer.addView(sidebarContent, new FrameLayout.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
||||||
|
|
||||||
View separator = new View(getContext());
|
|
||||||
var sepParams = new LinearLayout.LayoutParams(dp(1), ViewGroup.LayoutParams.MATCH_PARENT);
|
|
||||||
separator.setOutlineAmbientShadowColor(COLOR_BORDER);
|
|
||||||
layout.addView(separator, sepParams);
|
|
||||||
|
|
||||||
LinearLayout titleLayout = new LinearLayout(getContext());
|
|
||||||
titleLayout.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
titleLayout.setGravity(Gravity.CENTER);
|
|
||||||
titleLayout.setPadding(0, 0, 0, dp(32));
|
|
||||||
|
|
||||||
TextView title = new TextView(getContext());
|
TextView title = new TextView(getContext());
|
||||||
title.setText("PARROT");
|
title.setText("PARROT");
|
||||||
title.setTextSize(22);
|
title.setTextSize(26);
|
||||||
title.setGravity(Gravity.CENTER);
|
title.setTextColor(ParrotTheme.NEON_ACCENT);
|
||||||
title.setTextColor(COLOR_ACCENT);
|
title.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
titleLayout.addView(title);
|
sidebar.addView(title);
|
||||||
|
|
||||||
sidebarContent.addView(titleLayout);
|
TextView subtitle = new TextView(getContext());
|
||||||
|
subtitle.setText("CONTROL CENTER");
|
||||||
FrameLayout tabsContainer = new FrameLayout(getContext());
|
subtitle.setTextSize(10);
|
||||||
sidebarContent.addView(tabsContainer, new LinearLayout.LayoutParams(
|
subtitle.setTextColor(ParrotTheme.TEXT_MUTED);
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
|
subtitle.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
|
subtitle.setPadding(0, 0, 0, ParrotTheme.dp(40));
|
||||||
|
sidebar.addView(subtitle);
|
||||||
|
|
||||||
LinearLayout tabsLayout = new LinearLayout(getContext());
|
LinearLayout tabsLayout = new LinearLayout(getContext());
|
||||||
tabsLayout.setOrientation(LinearLayout.VERTICAL);
|
tabsLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
tabsLayout.setPadding(dp(12), 0, dp(12), 0);
|
sidebar.addView(tabsLayout, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
|
||||||
tabsContainer.addView(tabsLayout, new FrameLayout.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP));
|
|
||||||
|
|
||||||
|
|
||||||
FrameLayout contentArea = new FrameLayout(getContext());
|
FrameLayout contentArea = new FrameLayout(getContext());
|
||||||
contentArea.setId(R.id.content);
|
contentArea.setId(R.id.content);
|
||||||
var contentParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1f);
|
layout.addView(contentArea, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1f));
|
||||||
layout.addView(contentArea, contentParams);
|
|
||||||
|
|
||||||
String[] tabNames = {"Info", "General", "Discord"};
|
String[] tabNames = {"Dashboard", "Client Settings", "Discord RPC"};
|
||||||
Fragment[] tabFragments = {
|
Fragment[] tabFragments = { new InfoTabFragment(), new GeneralTabFragment(), new DiscordTabFragment() };
|
||||||
new InfoTabFragment(),
|
|
||||||
new GeneralTabFragment(),
|
|
||||||
new DiscordTabFragment()
|
|
||||||
};
|
|
||||||
|
|
||||||
View[] tabContainers = new View[tabNames.length];
|
|
||||||
View[] indicators = new View[tabNames.length];
|
View[] indicators = new View[tabNames.length];
|
||||||
TextView[] textViews = new TextView[tabNames.length];
|
TextView[] textViews = new TextView[tabNames.length];
|
||||||
|
View[] tabButtons = new View[tabNames.length];
|
||||||
|
|
||||||
for (int i = 0; i < tabNames.length; i++) {
|
for (int i = 0; i < tabNames.length; i++) {
|
||||||
final int index = i;
|
final int index = i;
|
||||||
|
FrameLayout tabBtn = new FrameLayout(getContext());
|
||||||
FrameLayout tabContainer = new FrameLayout(getContext());
|
tabButtons[i] = tabBtn;
|
||||||
|
|
||||||
View indicator = new View(getContext());
|
View indicator = new View(getContext());
|
||||||
indicator.setBackground(makeRoundedBg(COLOR_ACCENT, 2));
|
icyllis.modernui.graphics.drawable.ShapeDrawable indBg = new icyllis.modernui.graphics.drawable.ShapeDrawable();
|
||||||
indicator.setVisibility(View.INVISIBLE);
|
indBg.setCornerRadius(ParrotTheme.dp(4));
|
||||||
var indParams = new FrameLayout.LayoutParams(dp(3), dp(18), Gravity.START | Gravity.CENTER_VERTICAL);
|
indBg.setColor(ParrotTheme.NEON_ACCENT);
|
||||||
tabContainer.addView(indicator, indParams);
|
indicator.setBackground(indBg);
|
||||||
|
indicator.setAlpha(0f);
|
||||||
|
|
||||||
|
tabBtn.addView(indicator, new FrameLayout.LayoutParams(ParrotTheme.dp(4), ParrotTheme.dp(24), Gravity.START | Gravity.CENTER_VERTICAL));
|
||||||
|
|
||||||
TextView tabText = new TextView(getContext());
|
TextView tabText = new TextView(getContext());
|
||||||
tabText.setText(tabNames[index]);
|
tabText.setText(tabNames[index]);
|
||||||
tabText.setTextSize(14);
|
tabText.setTextSize(15);
|
||||||
tabText.setPadding(dp(24), 0, dp(16), 0);
|
tabText.setTextColor(ParrotTheme.TEXT_SUBTITLE);
|
||||||
tabText.setTextColor(COLOR_TEXT_DIM);
|
tabText.setPadding(ParrotTheme.dp(20), ParrotTheme.dp(12), 0, ParrotTheme.dp(12));
|
||||||
tabText.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
tabBtn.addView(tabText);
|
||||||
tabContainer.addView(tabText, new FrameLayout.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, dp(40)));
|
|
||||||
|
|
||||||
tabContainer.setOnClickListener(v -> {
|
tabBtn.setOnClickListener(v -> {
|
||||||
getChildFragmentManager().beginTransaction()
|
getChildFragmentManager().beginTransaction()
|
||||||
.setReorderingAllowed(true)
|
.setReorderingAllowed(true)
|
||||||
.replace(contentArea.getId(), tabFragments[index])
|
.replace(contentArea.getId(), tabFragments[index])
|
||||||
.commit();
|
.commit();
|
||||||
|
|
||||||
for (int j = 0; j < tabNames.length; j++) {
|
for (int j = 0; j < tabNames.length; j++) {
|
||||||
boolean selected = (j == index);
|
boolean active = (j == index);
|
||||||
textViews[j].setTextColor(selected ? 0xFFFFFFFF : COLOR_TEXT_DIM);
|
textViews[j].setTextColor(active ? ParrotTheme.TEXT_TITLE : ParrotTheme.TEXT_SUBTITLE);
|
||||||
tabContainers[j].setBackground(selected ? makeRoundedBg(COLOR_TAB_SELECTED, 8) : null);
|
ObjectAnimator.ofFloat(indicators[j], View.ALPHA, indicators[j].getAlpha(), active ? 1f : 0f).setDuration(200).start();
|
||||||
indicators[j].setVisibility(selected ? View.VISIBLE : View.INVISIBLE);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var tabParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(40));
|
var btnParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
tabParams.bottomMargin = dp(6);
|
btnParams.bottomMargin = ParrotTheme.dp(8);
|
||||||
tabsLayout.addView(tabContainer, tabParams);
|
tabsLayout.addView(tabBtn, btnParams);
|
||||||
|
|
||||||
tabContainers[index] = tabContainer;
|
|
||||||
indicators[index] = indicator;
|
indicators[index] = indicator;
|
||||||
textViews[index] = tabText;
|
textViews[index] = tabText;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView footer = new TextView(getContext());
|
|
||||||
String version = FabricLoader.getInstance().getModContainer("parrotmod")
|
|
||||||
.map(m -> m.getMetadata().getVersion().getFriendlyString()).orElse("?.?.?");
|
|
||||||
footer.setText("v" + version);
|
|
||||||
footer.setTextSize(10);
|
|
||||||
footer.setTextColor(0x33FFFFFF);
|
|
||||||
footer.setGravity(Gravity.CENTER);
|
|
||||||
footer.setPadding(dp(16), dp(12), dp(16), dp(12));
|
|
||||||
sidebarContent.addView(footer);
|
|
||||||
|
|
||||||
root.setAlpha(0);
|
root.setAlpha(0);
|
||||||
root.setScaleX(0.98f);
|
root.setScaleX(0.95f);
|
||||||
root.setScaleY(0.98f);
|
root.setScaleY(0.95f);
|
||||||
ObjectAnimator.ofFloat(root, View.ALPHA, 0, 1).setDuration(350).start();
|
ObjectAnimator.ofFloat(root, View.ALPHA, 0, 1).setDuration(400).start();
|
||||||
ObjectAnimator.ofFloat(root, View.SCALE_X, 0.98f, 1).setDuration(350).start();
|
ObjectAnimator.ofFloat(root, View.SCALE_X, 0.95f, 1).setDuration(500).start();
|
||||||
ObjectAnimator.ofFloat(root, View.SCALE_Y, 0.98f, 1).setDuration(350).start();
|
ObjectAnimator.ofFloat(root, View.SCALE_Y, 0.95f, 1).setDuration(500).start();
|
||||||
|
|
||||||
root.post(() -> {
|
root.post(() -> tabButtons[0].callOnClick());
|
||||||
tabContainers[0].callOnClick();
|
|
||||||
});
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int dp(float dp) {
|
|
||||||
return (int) (dp * getContext().getResources().getDisplayMetrics().density);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShapeDrawable makeRoundedBg(int color, float radius) {
|
|
||||||
ShapeDrawable d = new ShapeDrawable();
|
|
||||||
d.setCornerRadius(dp(radius));
|
|
||||||
d.setColor(color);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ShapeDrawable makeBorderedBg(int color, int strokeColor, float radius, float strokeWidth) {
|
|
||||||
ShapeDrawable d = new ShapeDrawable();
|
|
||||||
d.setCornerRadius(dp(radius));
|
|
||||||
d.setColor(color);
|
|
||||||
d.setStroke(dp(strokeWidth), strokeColor);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package de.winniepat.parrotmod.ui.util;
|
||||||
|
|
||||||
|
import icyllis.modernui.graphics.drawable.ShapeDrawable;
|
||||||
|
import icyllis.modernui.util.DisplayMetrics;
|
||||||
|
import icyllis.modernui.ModernUI;
|
||||||
|
|
||||||
|
public class ParrotTheme {
|
||||||
|
public static final int BG_WINDOW = 0xCC09090E;
|
||||||
|
public static final int BG_CARD = 0x601A1A24;
|
||||||
|
|
||||||
|
public static final int NEON_ACCENT = 0xFF00FF87;
|
||||||
|
|
||||||
|
public static final int TEXT_TITLE = 0xFFFFFFFF;
|
||||||
|
public static final int TEXT_SUBTITLE = 0xFFA0A5B5;
|
||||||
|
public static final int TEXT_MUTED = 0xFF6B7280;
|
||||||
|
|
||||||
|
public static final int BORDER_GLASS = 0x20FFFFFF;
|
||||||
|
public static final int BORDER_CARD = 0x15FFFFFF;
|
||||||
|
|
||||||
|
public static int dp(float dp) {
|
||||||
|
DisplayMetrics metrics = ModernUI.getInstance().getResources().getDisplayMetrics();
|
||||||
|
return (int) (dp * metrics.density);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShapeDrawable createGlassPanel(float radius, float strokeWidth) {
|
||||||
|
ShapeDrawable d = new ShapeDrawable();
|
||||||
|
d.setCornerRadius(dp(radius));
|
||||||
|
d.setColor(BG_WINDOW);
|
||||||
|
if (strokeWidth > 0) d.setStroke(dp(strokeWidth), BORDER_GLASS);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShapeDrawable createCard(float radius) {
|
||||||
|
ShapeDrawable d = new ShapeDrawable();
|
||||||
|
d.setCornerRadius(dp(radius));
|
||||||
|
d.setColor(BG_CARD);
|
||||||
|
d.setStroke(dp(1), BORDER_CARD);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user